Hi Matt,
I like to use a popup form to collect the password and call
it whenever I need to ask the user for one:
make a form
name --> usys_pw
(prefacing the name with "usys" means it is a user-system
object and will be hidden unless system objects are showing)
(form) caption --> Enter Password
label control
caption --> "Enter Password:"
(just so it shows up bigger than the titlebar)
textbox control
name --> EnterP
InputMask --> Password
code behind the form:
'-----------------------
Private Sub EnterP_AfterUpdate()
SetRight (Me.EnterP)
DoCmd.Close acForm, Me.Name
End Sub
Private Sub Form_Open(Cancel As Integer)
SetPW
End Sub
'-----------------------
then, in a general module
'-----------------------
Dim gBooPW As Boolean
Function SetPW()
gBooPW = False
End Function
Function GetPW() As Boolean
GetPW = gBooPW
End Function
Function SetRight(pPW) As Boolean
'you can use other logic
'to determine the correct password
gBooPW = IIf(Nz(pPW) = "secret", True, False)
End Function
'-----------------------
then, in the Open event for the form you want to protect:
'-----------------------
Private Sub Form_Open(Cancel As Integer)
DoCmd.OpenForm "usys_pw", , , , , acDialog
If Not GetPW() Then
MsgBox "You may not open this form", , "Incorrect
password"
Cancel = True
Exit Sub
End If
End Sub
'-----------------------
Have an awesome day
Warm Regards,
Crystal
MVP Microsoft Access
strive4peace2006 at yahoo.com