Password protect a button that opens a form

  • Thread starter Thread starter Sarah at DaVita
  • Start date Start date
S

Sarah at DaVita

I have a button that opens a form. I would like to make it so when clicked
it asks for a password if it gets what it expects it will open that form. If
the wrong or no password is entered I want it give a message and end
processing so the user just stays on the form they are on. Can someone help
me with that?
 
Private Sub Command0_Click()
Dim strpassword As String
strpassword = InputBox("enter your password")
If strpassword = "Your Password" Then
DoCmd.OpenForm "Your Form"
Else: End If
DoCmd.Close acForm, "Your Form"
End Sub
 
I forgot to mention, go to the onclick event of the form (click on the black
box in upper left hand corner), click on the code builder, type this in.
Golfinray
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Excel Protection 2
Password Protect Form 4
Password protected form allows access 3
Excel Excel macro and passwords 3
Passwords 2
Are password protected WiFi networks secure? 3
Form wrangle 2
Password Protected Form and Report 8

Back
Top