Need help on VBA codes for db password (1 Viewer)

accessfever

Registered User.
Local time
Today, 15:46
Joined
Feb 7, 2010
Messages
101
Hi I wanted to create a simple start up screen so user is required to enter a password then hit Enter key. The VBA codes then determines if the entered password is matched or not. If matched, then the start up screen will be closed and the switchboard is opened. If not matched, then a message of "the password is not correct" is displayed and exit the db. However, it seems like my codes are not correct:

Private Sub PassWd_Enter()

Dim intUserResponse As String
intUserResponse = PassWd.Text
If intUserResponse = "PasswordABC!" Then
DoCmd.Close
DoCmd.OpenForm ("Switchboard")
DoCmd.Maximize

Else
DoCmd.Close
DoCmd.Quit
End If

End Sub

Any help is appreciated!
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 15:46
Joined
Aug 30, 2003
Messages
36,132
Try the after update event. The enter event runs when focus "enters" the textbox, not when you hit enter.
 

accessfever

Registered User.
Local time
Today, 15:46
Joined
Feb 7, 2010
Messages
101
It worked. Thanks very much!
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 15:46
Joined
Aug 30, 2003
Messages
36,132
Happy to help!
 

Users who are viewing this thread

Top Bottom