phillbaker
Registered User.
- Local time
- Today, 10:35
- Joined
- Jun 29, 2008
- Messages
- 45
I have been trying to create a login form so people have to enter a username and password.
the username box is working as when i press the login button without a password it displays an error which is in the VB code. However if i try and do it with a password as well i get the following error.
The expression you entered as a query parameter produced this error: 'test'.
Below is the code im using:
'Check to see if data is entered into the UserName combo box
If IsNull(Me.cbo_login) Or Me.cbo_login = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
Me.cbo_login.SetFocus
Exit Sub
End If
'Check to see if data is entered into the password box
If IsNull(Me.txt_password) Or Me.txt_password = "" Then
MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
Me.txt_password.SetFocus
Exit Sub
End If
'Check value of password in Users to see if this
'matches value chosen in combo box
If Me.txt_password.Value = DLookup("[Password]", "[Users]", _
"[ID]=" & Me.cbo_login.Value) Then
ID = Me.cbo_login.Value
'Close logon form and open splash screen
DoCmd.Close acForm, "Login", acSaveNo
DoCmd.OpenForm "Splash_Screen"
Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, _
"Invalid Entry!"
Me.txt_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
hope someone can help i have made sure all the names of the text boxes are correct. Am i missing some brackets or " " somewhere.
the username box is working as when i press the login button without a password it displays an error which is in the VB code. However if i try and do it with a password as well i get the following error.
The expression you entered as a query parameter produced this error: 'test'.
Below is the code im using:
'Check to see if data is entered into the UserName combo box
If IsNull(Me.cbo_login) Or Me.cbo_login = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
Me.cbo_login.SetFocus
Exit Sub
End If
'Check to see if data is entered into the password box
If IsNull(Me.txt_password) Or Me.txt_password = "" Then
MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
Me.txt_password.SetFocus
Exit Sub
End If
'Check value of password in Users to see if this
'matches value chosen in combo box
If Me.txt_password.Value = DLookup("[Password]", "[Users]", _
"[ID]=" & Me.cbo_login.Value) Then
ID = Me.cbo_login.Value
'Close logon form and open splash screen
DoCmd.Close acForm, "Login", acSaveNo
DoCmd.OpenForm "Splash_Screen"
Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, _
"Invalid Entry!"
Me.txt_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
hope someone can help i have made sure all the names of the text boxes are correct. Am i missing some brackets or " " somewhere.