Hi,
there are many ways of achieving this. If you really just want a simple
password protection on a form with one password you can use an input box on
click event of the button which opens this form e.g.:
Dim strInput As String
Dim strMsg As String
strMsg = "Please enter password?"
strInput = InputBox(Prompt:=strMsg, title:="Password Please!")
If strInput = "YourPassword" Then
DoCmd.OpenForm "FormName"
Else
MsgBox("Wrong password, try again!")
End If
If you want to use different usernames with special assigned passwords you
could create a table which holds the usernames and passwords. Then you can
use the dlookup function on the on click event of a button to compare the
entered values in your login form (username textbox and password textbox)
with the values stored in the table e.g.:
Dim varUser As Variant, varPW as Variant
varUser = DLookup("[UsernameField]","tblUsers","[UsernameField] = '" &
Me!UsernameControl & "'")
varPW = DLookup("[PasswordField]","tblUsers","[PasswordField] = '" &
Me!PasswordControl & "'")
If varUser = Me!UsernameControl AND varPW = Me!PasswordControl Then
DoCmd.Openform "FormName"
Else
MsgBox("Wrong password, try again!")
Me!UsernameControl.SetFocus
End If
These are just a couple of examples...if you want to clarify what you are
after and this doesn't help you then let me know.
HTH
Good luck