I have almost completed this simple, semi-secure login screen. I have tblPassword with id, UserID and Pword fields. I have basic login screen with two text boxes and one command button. All works well except the UserID input has to match the UserID field perfectly or I get an Access error message "Invalid Use of Null". (If UserID is not typed correctly, I want to get my error message).
A wrong password typed in produces my desired results and if everything is correct it opens frmMAIN. Any code breakers see the problem?
Private Sub cmdlogon_Click()
On Error GoTo Err_cmdlogon_Click
Dim strPassword As String
strPassword = DLookup("[Pword]", "tblPassword", "[UserId] = '" & Text1 & "'"
If LCase(strPassword) = LCase(Text2) Then
Visible = False
DoCmd.OpenForm "frmMain", acNormal, , , , acWindowNormal
Else
MsgBox "Can't log on. Username and password do not match. " _
& Chr(13) & "Please try again", vbCritical
End If
Exit_cmdlogon_Click:
Me![Text1] = ""
Me![Text2] = ""
Exit Sub
Err_cmdlogon_Click:
MsgBox Err.Description
Resume Exit_cmdlogon_Click
End Sub
Here's an easy one: How do I get the cursor in the first text box everytime the form opens.
Thanks in advance,
Tigerdude
A wrong password typed in produces my desired results and if everything is correct it opens frmMAIN. Any code breakers see the problem?
Private Sub cmdlogon_Click()
On Error GoTo Err_cmdlogon_Click
Dim strPassword As String
strPassword = DLookup("[Pword]", "tblPassword", "[UserId] = '" & Text1 & "'"
If LCase(strPassword) = LCase(Text2) Then
Visible = False
DoCmd.OpenForm "frmMain", acNormal, , , , acWindowNormal
Else
MsgBox "Can't log on. Username and password do not match. " _
& Chr(13) & "Please try again", vbCritical
End If
Exit_cmdlogon_Click:
Me![Text1] = ""
Me![Text2] = ""
Exit Sub
Err_cmdlogon_Click:
MsgBox Err.Description
Resume Exit_cmdlogon_Click
End Sub
Here's an easy one: How do I get the cursor in the first text box everytime the form opens.
Thanks in advance,
Tigerdude