Thread: Login code problems
05-01-06, 07:36 #1Registered User
- Join Date
- May 2006
Unanswered: Login form code problems
Hello all, i am trying to implement a login form for users, but i am having problems with the code for cmdLogin_Click(). It keeps saying there is a run time error 2501 on this line of code. I'm fairly new to VBA, can anyone help? Here is the code for the on click event, the line in red which is the filter is the one i am having problems with.
Private Sub cmdLogin_Click()
'Used when the user moves out of txtPassword
'Filter the record for the form the LoginID (unique primary key)
'Filter for matching login id
DoCmd.ApplyFilter , "[LoginID] = forms![frmLogin]!txtLogin"
'If a match is found then the the LoginID and Password from the table will be found in bound fields on the form
'They can be used to check with what the user has typed in
If IsNull(LoginID) Then 'No match for LoginID found
myDisplayWarningMessage "Invalid Login ID"
ElseIf Password <> txtPassword Or IsNull(txtPassword) Then 'Invalid or missing password
myDisplayWarningMessage "Invalid Password"
Else 'Valid log in, password
myOKBox "Welcome " & FirstName & "" & LastName & ""
'Open the main menu
'Close this form
Last edited by c02dm; 05-01-06 at 08:08.
05-01-06, 12:01 #2Moderator
- Join Date
- Dec 2004
- Madison, WI
You can try the code below for getting users login.Expert Database Programming
MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)