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
 
Back
Top