K
kay
Thanks in advance for your time and help.
I have created Login form. But My code is not working. When I click on Login
button, the control goes to On Error GoTo Err_LoginButton_Click
I dont know whats wrong with the code:
here is the code:
Private Sub LoginButton_Click()
On Error GoTo Err_LoginButton_Click
Dim rs As DAO.Recordset
Dim strUser As String
Dim strPassword As String
txtEmpID.SetFocus
strUser = txtEmpID
txtEmpPass.SetFocus
strPassword = txtEmpPass
Set rs = CurrentDb.OpenRecordset("Select EmpID, EmpPassword from tblEmpID
where EmpID = " & strUser & " And EmpPassword = " & strPassword & " ",
dbOpenSnapshot)
If rs.EOF Then
DoCmd.OpenForm "frmTrackingV2"
Else
MsgBox "Password Invalid"
Me.txtEmpPass.SetFocus
End If
Exit_LoginButton_Click:
Exit Sub
Err_LoginButton_Click:
MsgBox "Code is not working"
MsgBox Err.Description
MsgBox Err.HelpFile
MsgBox Err.HelpContext
Resume Exit_LoginButton_Click
End Sub
I have created Login form. But My code is not working. When I click on Login
button, the control goes to On Error GoTo Err_LoginButton_Click
I dont know whats wrong with the code:
here is the code:
Private Sub LoginButton_Click()
On Error GoTo Err_LoginButton_Click
Dim rs As DAO.Recordset
Dim strUser As String
Dim strPassword As String
txtEmpID.SetFocus
strUser = txtEmpID
txtEmpPass.SetFocus
strPassword = txtEmpPass
Set rs = CurrentDb.OpenRecordset("Select EmpID, EmpPassword from tblEmpID
where EmpID = " & strUser & " And EmpPassword = " & strPassword & " ",
dbOpenSnapshot)
If rs.EOF Then
DoCmd.OpenForm "frmTrackingV2"
Else
MsgBox "Password Invalid"
Me.txtEmpPass.SetFocus
End If
Exit_LoginButton_Click:
Exit Sub
Err_LoginButton_Click:
MsgBox "Code is not working"
MsgBox Err.Description
MsgBox Err.HelpFile
MsgBox Err.HelpContext
Resume Exit_LoginButton_Click
End Sub