Hi all. I'm having difficulty making a log-in screen. i am using an adoc contorl called adoClerk, which contains only two fields and ClerkId and Password. The ClerkId is a autonum and password is text. I Have two text boxes that need to be read from this screen txtClerId and txtPassowrd. I have a button called Login. This button is suppposed to have the code eneterd in that checks and opes the record source, but i am having an error with the password. If i can get some advice on how to make this simpler or help with debugging. Either one is good. Here is my code I have so far.
Private Sub cmdLogIn_Click()
' finds the matching clerk Id
Dim tempRecordSet As Recordset
Set tempRecordSet = adoClerk.Recordset("select * from Clerk where UCase(trim(ClerkId)) = '" & UCase(Trim(txtClerkId)) & "'")
'retrieve the Password field from the Clerk table if the ClerkID matches the txtClerkId Field
If tempRecordSet.RecordCount <> 0 Then
Password = UCase(Trim(tempRecordSet("Password")))
End If
'close the recordset and release the recordset object variable
tempRecordSet.Close
Set tempRecordSet = Nothing
'check the password
If Password <> UCase(Trim(txtPassword)) Then
MsgBox "Incorrect password", vbExclamation
txtPassword.SetFocus
Else
'passwords match, allow the user to procede to the desk top
Unload Me 'unloads the form
FrmMain.Show vbModal
End If
End Sub