Good afternoon.
I searched the forum for assistance in creating a user login form for db access. I came acrosss this VB code which is partially working, but I'm experiencing an error when the password is entered. If the incorrect password is entered, I get the prompt box I've coded. If the correct password is entered, I get a "run-time error '3164' Field cannot be updated" error.
If anyone's willing to assist, here's the code that I've enters for this. I've bold/underlined/italicized the portion creating the error.
Private Sub Command37_Click()
'Check to see if data is entered into the UserName combo box
If IsNull(Me.Combo17) Or Me.Combo17 = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
Me.Combo17.SetFocus
Exit Sub
End If
'Check to see if data is entered into the password box
If IsNull(Me.Text31) Or Me.Text31 = "" Then
MsgBox "You must enter a valid Password.", vbOKOnly, "Required Data"
Me.Text31.SetFocus
Exit Sub
End If
'Check value of password in the tblLogin to see if this matches value chosen in combo box
If Me.Text31.Value = DLookup("Password", "tblLogin", _
"[ID]=" & Me.Combo17.Value) Then
ID = Me.Combo17.Value
'Close logon form and open navigation screen
DoCmd.Close acForm, "frmLogin", acSaveNo
DoCmd.OpenForm "frmNavigation"
Else
MsgBox "Password Invalid. Please try again.", vbOKOnly, _
"Invalid Entry"
Me.Text31.SetFocus
End If
'If User Enters incorrect password 3 times database wil shutdown
intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts > 3 Then
MsgBox "You do not have access to this database. Please contact administrator.", _
vbCritical, "Restricted Access!"
Application.Quit
End If
End Sub