I am trying to use the code below to validate a User when they log into the database but I am getting RunTime Error 2001.
Code:
Private Sub ButtonLogin_Click()
Dim strUserName As String
Dim strPassword As String
Dim strUserNamePassword As String
'Combine User Name and Password entered into Login Form
strUserNamePassword = txtUserName & txtPassword
'Search for User Name and Password entered from the Login Form in the Tbl_Representatives
strUserName = Nz(DLookup("User_Login", "Tbl_Representatives", "User_Login= " & Forms![Frm_Login]!txtUserName), 0)
strPassword = Nz(DLookup("User_Password", "Tbl_Representatives", "User_Password= " & Forms![Frm_Login]!txtPassword), 0)
'Validate the User Name and Password exists in the Tbl_Representatives
If strUserNamePassword = (strUserName & strPassword) Then
DoCmd.OpenForm "Frm_Main"
DoCmd.Close acForm, "Frm_Login"
Else
lblLoginFailure.Visible = True