Password on a form

rgeinosky

New member
Local time
Today, 04:00
Joined
Sep 5, 2008
Messages
4
I am relatively new to this.
I have been asked to put a control on a form to open another form but to have it password protected so only certain users can view. Is this possible in VBA and if so what is the syntax.

Thanks

Bob
 
There are several ways to do this...

This being one of them...

With this method when the password is typed it can be seen...Others make the password like ****

Just wanted to give you some type of answer...

On the "On Click" Event of your button to open the form just add this code...and change the bolded areas

' Code Starts Here

Dim strInput As String
Dim strMsg As String

Beep

strMsg = "This option is password protected..." & vbCrLf & vbLf & "Please enter the ''Password'' to gain access."
strInput = InputBox(Prompt:=strMsg, title:="Access Password Required")

If strInput = "A PASSWORD HERE" Or _
strInput = "ANOTHER PASSWORD HERE" Then 'password is correct

DoCmd.OpenForm "YOUR FORM NAME"

Else 'password is incorrect
MsgBox "Incorrect Password!" & vbCrLf & vbLf & "You have entered an ''Invalid Password''" & vbCrLf & vbLf & "Please Try Again.", vbCritical, "Invalid Password"
Exit Sub
End If

' Code Ends Here

Hope this helps...if you want the password hidden just let me know and I'll answer you tomorrow with that inforamtion.
 
hi don,

if you could add the hidden version, that would be quite good :)


nige
 
I have attached a sample database.

This uses the InputBox method...However, it does hide the password.

The sample database is in a Access 2000 format. It will work in Access 2007 as well.

Hope this helps...
 

Attachments

Last edited:

Users who are viewing this thread

Back
Top Bottom