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!!!! :)

Edited 4 Years Ago by Ezzaral: Moved to correct forum and added code formatting. Please pay attention to such things in the future.

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

This article has been dead for over six months. Start a new discussion instead.