Passwords (2 Viewers)

UKBobby

Fly Me To The Moon
Local time
Today, 07:02
Joined
Dec 31, 2002
Messages
23
Hi

I'm new to this board but though I'd ask you good people for a bit of help. I've inherited some code which validates a password held on a table with data from a form. The code works but I can't get it to refresh the data. I.E. if I put correct userid and password it works fine but if I put an incorrect one in then a correct one in it tells me its incorrect. If you see what I mean

Anyway here's the code:

Private Sub Password_AfterUpdate()
DoCmd.OpenForm "025Frm_PasswordVer", , , "[Wage_no]= Forms![025Frm_Password]![User_id]", , acHidden

If IsNull(Forms![025Frm_PasswordVer]![wage_no]) Then
MsgBox "Wage Number is Invalid"
Forms![025Frm_Password]![User_id] = Null
Forms![025Frm_Password]![Password] = Null
Me![User_id].SetFocus

ElseIf Forms![025Frm_PasswordVer]![Password] <> Forms![025Frm_Password]![Password] Then
MsgBox "Incorrect Password Entered"
Forms![025Frm_Password]![User_id] = Null
Forms![025Frm_Password]![Password] = Null
Me![User_id].SetFocus

Else: DoCmd.Close
DoCmd.OpenForm "MainMenu"

End If

End Sub

Any help would be greatly appreciated :)
 

Travis

Registered User.
Local time
Yesterday, 23:02
Joined
Dec 17, 1999
Messages
1,332
This Line is your culprit:
DoCmd.OpenForm "025Frm_PasswordVer", , , "[Wage_no]= Forms![025Frm_Password]![User_id]", , acHidden

Your code should work if you use the same user_id and just mistyped the password.

At the end of your code you need to close the 025Frm_PasswordVer" Form.

By leaving this form open with a filter you can't change the Values that it is verifing.

While this approach works, it is not the best method to do this.

Look at using the DLookup or opening a Recordset for verification purposes. Opening a hidden Form (That does not close until the app is exited) can eventually get expensive.
 

UKBobby

Fly Me To The Moon
Local time
Today, 07:02
Joined
Dec 31, 2002
Messages
23
Thanks Travis - that works great. Its only a small db. Now I can have a good New Year.

:D
 

Users who are viewing this thread

Top Bottom