password protect a form (1 Viewer)

sambucaman

Registered User.
Local time
Today, 13:55
Joined
May 6, 2010
Messages
41
Hi guys / girls!

I'm looking to password protect a single form, lets call it frmAdmin.

I have looked into various different login methods, with access restrictions for each user, but to be honest this is overkill. I am the only admin, and I have a form I'd like to be able to access without the hassle of giving everyone a login. I also don't like the rigmarole of re-reopening the DB with SHIFT held, and unhiding the main DB windows (access 2003 BTW)

So, I'd like a button on the main users switchboard, that when clicked will open a password box, and then take me to another form.

Any ideas, code, or samples would be really helpful.

Thanks in advance
 

Trevor G

Registered User.
Local time
Today, 21:55
Joined
Oct 1, 2009
Messages
2,341
Add a command button on your switchboard form and then open the properties and name the command button cmdPassword then change the caption to something useful, then select the Event Tab and then On Click Event click the elpise button and select Code Builder add this code and save your form then test it.

You can change the password before you do that and also the form name to open

Private Sub cmdPassword_Click()
Dim strPassword As String
strPassword = "YourPassword" 'Change the password
If InputBox("Please Enter Your password") = strPassword Then
DoCmd.OpenForm "frmClient" 'Change the form name
Else
MsgBox "Your password isn't valid", vbInformation, "Sample"
Exit Sub
End If

End Sub
 

sambucaman

Registered User.
Local time
Today, 13:55
Joined
May 6, 2010
Messages
41
thats perfect for what I need. Only addition thing I would like is to mask the password ie show "********" instead of "password"
Any suggestions?
 

Trevor G

Registered User.
Local time
Today, 21:55
Joined
Oct 1, 2009
Messages
2,341
Ok rather than use an inputbox design a form to act like the inputbox and you can mask a textbox to password. But it works the same.
 

Users who are viewing this thread

Top Bottom