Passwords on Forms

davey3389

Registered User.
Local time
Today, 11:00
Joined
Jul 16, 2012
Messages
30
Can some tell me how I would go about putting a password on a form when someone tries to open it

The form name is "Employee Details"

and also where would I set/change the password

Many Thanks

Ben
 
You can do this by adding a command button and then using some code like this:

Private Sub Command31_Click()
Dim strPassword As String
strPassword = "Test"
If InputBox("Please enter the password") = strPassword Then
DoCmd.OpenForm "frmClient"
Else
MsgBox "Incorrect Password used"
End If
End Sub
 
Where do I type this code into
 
If you have a start form add a command button (in design view) and then open the properties for the command button, look at the Event Tab and then click the On Click Event and use the 3 dots to the right and select Code Builder copy and paste the code I added make sure you change the password to the one you want in the code and also don't copy the first line or last line as this is the command button name.
 
I did the code, click the button it asked for the password and then when I typed it in i got the error message: Compile error: Expected End Sub

Any suggestions?

Thanks
 
At the end of the code does it show you

End Sub
 
Here is a copy of the code:

*Note the top line is highlighted yellow


Private Sub Form_Open(Cancel As Integer)
Private Sub Command31_Click()
Dim strPassword As String
strPassword = "Test"
If InputBox("Please enter the password") = strPassword Then
DoCmd.OpenForm "frmClient"
Else
MsgBox "Incorrect Password used"
End If
End Sub
 
On this subject is there away to make the password come up as **** rather than a visible password
 

Users who are viewing this thread

Back
Top Bottom