This was suggested to me by someone on this board. It works really well. Hope it helps you.
The following code is attached to the on click event of a button that I have that opens a "Password" form that I created. The password form has a text box for the user to key in the passwork, an OK button to open the desired form if the password is correct, and a cancel button to close the form and return to the previous menu.
Private Sub Maint_Menu_Button_Click()
On Error GoTo Err_Maint_Menu_Button_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Passwordfrm"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Maint_Menu_Button_Click:
Exit Sub
Err_Maint_Menu_Button_Click:
MsgBox Err.Description
Resume Exit_Maint_Menu_Button_Click
End Sub
___________________
This code is attached to the "OK" button on my password form.
Private Sub Command2_Click()
On Error GoTo Err_Command2_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "YourFormNameHERE"
If Me.Text0 = "yourpassword" Then
DoCmd.Close
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
MsgBox "Incorrect Password!"
Me.Text0 = ""
End If
Exit_Command2_Click:
Exit Sub
Err_Command2_Click:
MsgBox Err.Description
Resume Exit_Command2_Click
End Sub
________________
This is the code attached to the cancel button on the password form.
Private Sub Command3_Click()
On Error GoTo Err_Command3_Click
DoCmd.Close
Exit_Command3_Click:
Exit Sub
Err_Command3_Click:
MsgBox Err.Description
Resume Exit_Command3_Click
End Sub