how can i limit the borrowing of books in our system.
the user is only allowed to borrow books 3 times a day..
so if the user reaches the limit,.the system will not allow the user to borrow books anymore.

here is our codes but it does not work well..so we need help.. tnx!!

Private Sub TextBox11_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox11.TextChanged
con = New OleDbConnection("Provider = Microsoft.ace.oledb.12.0; data source=|DataDirectory|\AutomatedLibrarySystem.accdb")
cmd = New OleDbCommand("Select * from Borrowing where Username='" + TextBox11.Text + "'", con)
con.Open()
dr = cmd.ExecuteReader()
If (dr.Read() = True) Then
disDate.Text = dr(10)
If disDate.Text <> TextBox6.Text Then
num = 1
num = num + 1
NumBookBor.Text = num
If NumBookBor.Text.Length = 3 Then
MsgBox("kfdshfklghnl")
End If
End If
End If

thank you so much!!!! :)

Hi,

Write the code in LostFocus event...
and change the sql statement to query for date condition as well...

Dim TNo As Integer
TNo = 0
con = New OleDbConnection("Provider = Microsoft.ace.oledb.12.0; " _
    data source=|DataDirectory|\AutomatedLibrarySystem.accdb")
cmd = New OleDbCommand("Select Count(*) from Borrowing where Username='" _
    & TextBox11.Text + "' And MyDateFld = #" & TextBox6.Text & "#", con)
con.Open()
TNo = cmd.ExecuteScalar()
If TNo >= 3 Then
    MsgBox("Check Limit....")
End If

Change date field name accordingly...

Regards
Veena

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.