Hi,
I have created the following code to use on a login screen but when used under a runtime environment causes runtime error and is giving me a headache.
CODE:
Private Sub Command7_Click()
On Error GoTo Err_Command7_Click
Dim Value As Variant
Dim stDocName As String
Dim stLinkCriteria As String
DoCmd.SetWarnings (WarningsOff)
Value = DLookup("[ID]", "Tbl_users", "[ID] = '" & Forms![Frm_login]![User ID] & "' and [Password] = '" & Forms![Frm_login]![Password] & "'")
If Value = Forms![Frm_login]![User ID] Then
stDocName = "Frm_main_menu"
DoCmd.OpenQuery "Qry_know_logged_in_users"
stLinkCriteria = "[ID]=" & "'" & Me![User ID] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Forms![Frm_login].Visible = False
Else
DoCmd.OpenForm "Frm_login_error"
End If
Exit_Command7_Click:
Exit Sub
Err_Command7_Click:
MsgBox Err.Description
Resume Exit_Command7_Click
End Sub
Can anyone see where I am going wrong here?
Many thanks! Your all stars!
I have created the following code to use on a login screen but when used under a runtime environment causes runtime error and is giving me a headache.
CODE:
Private Sub Command7_Click()
On Error GoTo Err_Command7_Click
Dim Value As Variant
Dim stDocName As String
Dim stLinkCriteria As String
DoCmd.SetWarnings (WarningsOff)
Value = DLookup("[ID]", "Tbl_users", "[ID] = '" & Forms![Frm_login]![User ID] & "' and [Password] = '" & Forms![Frm_login]![Password] & "'")
If Value = Forms![Frm_login]![User ID] Then
stDocName = "Frm_main_menu"
DoCmd.OpenQuery "Qry_know_logged_in_users"
stLinkCriteria = "[ID]=" & "'" & Me![User ID] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Forms![Frm_login].Visible = False
Else
DoCmd.OpenForm "Frm_login_error"
End If
Exit_Command7_Click:
Exit Sub
Err_Command7_Click:
MsgBox Err.Description
Resume Exit_Command7_Click
End Sub
Can anyone see where I am going wrong here?
Many thanks! Your all stars!