Simon said:
I would like to restrict access to a couple of forms what would be the
easiest way of doing this?
The best way would be to implement User-level security, but the easiest way
is to set up a simple password on the form, then convert the file to an MDE
so the users can't see the code. In the restricted form's Open event, paste
this:
Private Sub Form_Open(Cancel As Integer)
If (Me.OpenArgs = "OpenSesame") Then
' Open it.
Else
Cancel = True
End If
End Sub
On another form, create a button and paste this into it:
Private Sub cmdOpenRestrictedForm_Click()
On Error GoTo ProcErr
Dim pwd As String
pwd = InputBox("What's the password?")
DoCmd.OpenForm "frmRestricted", , , , , , pwd
Exit Sub
ProcErr:
If (Err.Number = 2501) Then
MsgBox "Sorry. Incorrect password."
Else
MsgBox "Error #" & Err.Number & vbCrLf & Err.Description
End If
Err.Clear
End Sub