Runtime error 3075 syntax error in string '[username=2]'
Hi,
I am trying to make a username and password form that logs you onto my database. I have a small form with an unbound combo box that you can select username and then underneath another text box to type a password. Underneath that I have a button which if the username and password values are correct takes you to the home screen. I have a problem with the D lookup part of my expression, I think i'm missing some quotes but i'm not sure. The unbound combo box has 2 columns ID, and Username but focuses on the username using the column widths. Please can someone help. expression string below.
Private Sub Command7_Click()
'Check to see if data is entered into the UserName combo box
If IsNull(Me.Username) Or Me.Username = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
Me.Username.SetFocus
Exit Sub
End If
'Check to see if data is entered into the password box
If IsNull(Me.Password) Or Me.Password = "" Then
MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
Me.Password.SetFocus
Exit Sub
End If
'Check value of password in tblEmployees to see if this
'matches value chosen in combo box
If Me.Password.Value = DLookup("ID", "UsersT", _
"[Username]=" & Me.Username.Value & "'") Then
ID = Me.Username.Value
'Close logon form and open splash screen
DoCmd.Close acForm, "UsersForm", acSaveNo
DoCmd.OpenForm "Mainmenu"
Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, _
"Invalid Entry!"
Me.Password.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