User Log In Form

Joe B.

Registered User.
Local time
Today, 00:19
Joined
Mar 16, 2012
Messages
34
Having a issue with the login screen I created. I have created a login form for the users in which the user enters their Employee Name and Password. On the "Go" button I have put the following code to validate the Employee Name and Password are in the "Employees" Table:
If Me.Password = DLookup("Password", "Employees", "EmployeeName='" & Me.EmployeeName & "'") Then
DoCmd.Close acForm, "SplashScreen"
Else
MsgBox "You have entered an incorrect Employee Name and Password combination. Please Try Again"
End If
End Sub

It works fine for the first user record in the table but for all subsequent users I receive the error message eventhough the Employee Name and Password combination is correct.

Appreciate all the help.

Joe B
 
Sorry you got chased off your own thread. The code looks okay offhand. Do you know how to set a breakpoint so you can test the value coming from the form when it fails?

http://www.baldyweb.com/Debugging.htm
 
I have never done this before. I read the attachment but am still a little confused. I set the breakpoint on: If Me.Password = DLookup("Password", "Employees", "EmployeeName='" & Me.EmployeeName & "'") Then. Is this the right place? Then I click the Step Into function on the Debug menu but nothing happened.
 
If you set the breakpoint and then run the code, when it stops at that point you can either hover over the form value to see what it is or type:

?Me.EmployeeName

in the Immediate window and see what the value is. Or can you post the db here? The form isn't bound, is it? Might it be looking at the first record because of that? Typically a login form would not be bound.
 
The form is unbound. When I hover over Me.EmployeeName it shows "Me.EmployeeName = "5" which is the id of Employee Name entered in the Employee table. When I hover over Me.Password I get the correct password for this employee. Is the problem that the code is identifying the ID rather than the Employee name? If so how is this corrected?
 
Try this, correcting the names:

If Me.Password = DLookup("Password", "Employees", "EmployeeID=" & Me.EmployeeName) Then
 
I change the code as above and then received this error Run Time Error 2471 The expression you entered as a query parameter produced this error: 'EmployeeID'
 
PBaldy. . .Have to run off for a while. Ill check back with you later. Thanks for your help
 
Is that the correct field name for the ID field? Basically you have to compare apples to apples. We either need to change the first part to be the ID field or the second to be the name (perhaps using the Column property if it's a combo).
 
Paul,

That worked. Thanks for all your help. You are the best.

Joe B.
 

Users who are viewing this thread

Back
Top Bottom