Form Password

P-C-Surgeon

Board Regular
Joined
Sep 24, 2004
Messages
115
Is there a way to create a link on a form which will open up another form but requres a password to open the 'password protected form'? Or should I just create my first form, which doesn't need a password, with a hidden link? I do have several forms which I don't want people to get into so I am trying to restrict access to these forms. Any ideas? Thanks for any suggestions.
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Hi

Insert the following code into the 'On Open' event of the form you want to protect :

Code:
Private Sub Form_Open(Cancel As Integer)

Dim PW As String

'Use either a DLookup to a table or hardcode the password in this code
'The line below is to extract the password from a table
PW = DLookup("[MyPasswordField]", "MyTable")

'Or the line below is to hard-code the password (delete one)
PW = "MyPassword"

If InputBox("Enter Administration Password ", "Password Required") <> PW Then
    MsgBox "Incorrect Password"
    DoCmd.Close acForm, "MyFormName", acSaveNo
    Exit Sub
End If

DoCmd.Restore

End Sub

Change any of the items prefixed with "My' to your actual field or table names. If the user tries to open the form, then the must enter the correct password to open the form.

HTH, Andrew :)
 
Upvote 0

Forum statistics

Threads
1,214,652
Messages
6,120,747
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top