This forum has saved me so many times. Thanks to all the experts. I hope to get good enough to contribute and pay back (or pay forward as it were)...anyway...
I know I should look at and perhaps use the "on-board" security in MS Access..but I'm building an application that needs a sign on form...I have the form and the table all set.
Searching the forum I found "Ghudson's audit trail code" and I've tried to build on that.
table: tblUsers
fields: UserID and UserPWD
form: frmTestLogin
Unbound fields: txtUser and txtPWD
When I execute the code...as follows...I get a "Canceled Previous Operation" error on the first DLookup statement. I've tried everything I know to find an answer. Any suggestions?
Private Sub cmdOK_Click()
Dim strUser As String
Dim strPWD As String
Dim intUSL As Integer
'Sign into program - ask for Users name
If IsNull(Me.[txtUser]) Then
MsgBox "Please Enter Your User Name"
Me![txtPWD] = ""
Me![txtUser].SetFocus
Exit Sub
End If
'validates User Name
If IsNull(DLookup("[UserID]", "tblUsers", "[UserID] = " & Me.txtUser)) Then
MsgBox "Not A Valid User Name" 'not a valid User Name returns to Name input field
Me![txtUser] = ""
Me![txtPWD] = ""
Me![txtUser].SetFocus
Exit Sub
End If
' validates User Name and Password
If IsNull(DLookup("[UserID]", "tblUsers", "[UserID] = " & Me.[txtUser] & " and [UserPWD] ='" & Me.[txtPWD] & "'")) Then
MsgBox "Not A Valid User Name or password" 'not a valid User Name returns to Name input field
Me![txtUser] = ""
Me![txtPWD] = ""
Me![txtUser].SetFocus
Exit Sub
End If
'validates User Name and Password
If Not IsNull(DLookup("[UserID]", "tblUsers", "[UserID] = " & Me.txtUser & " and [UserPWD] ='" & Me.[txtPWD] & "'")) Then
DoCmd.OpenForm "Switchboard"
'opens "Switchboard" form
DoCmd.Close acForm, "frmTestLogin"
End If
End Sub
I know I should look at and perhaps use the "on-board" security in MS Access..but I'm building an application that needs a sign on form...I have the form and the table all set.
Searching the forum I found "Ghudson's audit trail code" and I've tried to build on that.
table: tblUsers
fields: UserID and UserPWD
form: frmTestLogin
Unbound fields: txtUser and txtPWD
When I execute the code...as follows...I get a "Canceled Previous Operation" error on the first DLookup statement. I've tried everything I know to find an answer. Any suggestions?
Private Sub cmdOK_Click()
Dim strUser As String
Dim strPWD As String
Dim intUSL As Integer
'Sign into program - ask for Users name
If IsNull(Me.[txtUser]) Then
MsgBox "Please Enter Your User Name"
Me![txtPWD] = ""
Me![txtUser].SetFocus
Exit Sub
End If
'validates User Name
If IsNull(DLookup("[UserID]", "tblUsers", "[UserID] = " & Me.txtUser)) Then
MsgBox "Not A Valid User Name" 'not a valid User Name returns to Name input field
Me![txtUser] = ""
Me![txtPWD] = ""
Me![txtUser].SetFocus
Exit Sub
End If
' validates User Name and Password
If IsNull(DLookup("[UserID]", "tblUsers", "[UserID] = " & Me.[txtUser] & " and [UserPWD] ='" & Me.[txtPWD] & "'")) Then
MsgBox "Not A Valid User Name or password" 'not a valid User Name returns to Name input field
Me![txtUser] = ""
Me![txtPWD] = ""
Me![txtUser].SetFocus
Exit Sub
End If
'validates User Name and Password
If Not IsNull(DLookup("[UserID]", "tblUsers", "[UserID] = " & Me.txtUser & " and [UserPWD] ='" & Me.[txtPWD] & "'")) Then
DoCmd.OpenForm "Switchboard"
'opens "Switchboard" form
DoCmd.Close acForm, "frmTestLogin"
End If
End Sub