G
Guest
Hey all,
I've been working with this code for a while, and I'm hoping to get some
help with a problem I'm running into at the end.
I have a login form that is being set up so users must login with a username
and password before they can access the main form in the database. Only
problem is, when users enter their info and hit enter...nothing happens. When
I debugged step by step, it told me I had a syntax error, so I'm guessing
that may be the problem?
<B>Here's all the code:</B>
Private Sub cmdLogin_Click()
'Check to see if data is entered into the UserName combo box
If IsNull(Me.cboEmployee) Or Me.cboEmployee = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
Me.cboEmployee.SetFocus
Exit Sub
End If
'Check to see if data is entered into the password box
If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
Me.txtPassword.SetFocus
Exit Sub
End If
'Check value of password in tblEmployees to see if this
'matches value chosen in combo box
Dim strFilter As String
strFilter = "[EmployeeID]= " & Str(Me.cboEmployee.Value) & "'"
If Me.txtPassword.Value = DLookup("strEmpPassword", "tblemployees",
strFilter) Then
<B>'When I reach the above If line in debug mode, it tells me "Run time
error 3075,"syntax error in string in query expression '[EmployeeID]=
5079".</B>
'Close logon form and open splash screen
DoCmd.OpenForm "NewDailyReport"
DoCmd.Close acForm, "StartForm", acSaveNo
Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry!"
Me.txtPassword.SetFocus
End If
'If User Enters incorrect password 3 times database will shutdown
intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts > 3 Then
MsgBox "You do not have access to this database.Please contact admin.",
vbCritical, "Restricted Access!"
Application.Quit
End If
End Sub
Private Sub cboEmployee_AfterUpdate()
'After selecting user name set focus to password field
Me.txtPassword.SetFocus
End Sub
<B>Thanks so much!</B>
I've been working with this code for a while, and I'm hoping to get some
help with a problem I'm running into at the end.
I have a login form that is being set up so users must login with a username
and password before they can access the main form in the database. Only
problem is, when users enter their info and hit enter...nothing happens. When
I debugged step by step, it told me I had a syntax error, so I'm guessing
that may be the problem?
<B>Here's all the code:</B>
Private Sub cmdLogin_Click()
'Check to see if data is entered into the UserName combo box
If IsNull(Me.cboEmployee) Or Me.cboEmployee = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
Me.cboEmployee.SetFocus
Exit Sub
End If
'Check to see if data is entered into the password box
If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
Me.txtPassword.SetFocus
Exit Sub
End If
'Check value of password in tblEmployees to see if this
'matches value chosen in combo box
Dim strFilter As String
strFilter = "[EmployeeID]= " & Str(Me.cboEmployee.Value) & "'"
If Me.txtPassword.Value = DLookup("strEmpPassword", "tblemployees",
strFilter) Then
<B>'When I reach the above If line in debug mode, it tells me "Run time
error 3075,"syntax error in string in query expression '[EmployeeID]=
5079".</B>
'Close logon form and open splash screen
DoCmd.OpenForm "NewDailyReport"
DoCmd.Close acForm, "StartForm", acSaveNo
Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry!"
Me.txtPassword.SetFocus
End If
'If User Enters incorrect password 3 times database will shutdown
intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts > 3 Then
MsgBox "You do not have access to this database.Please contact admin.",
vbCritical, "Restricted Access!"
Application.Quit
End If
End Sub
Private Sub cboEmployee_AfterUpdate()
'After selecting user name set focus to password field
Me.txtPassword.SetFocus
End Sub
<B>Thanks so much!</B>