Hi,
Are you using the Access built-in Switchboard Manager
feature?
If so, follow these steps:
1. Make your small password form have the following
properties:
-Scroll Bars No
-Record Selectors No
-Navigation Buttons No
-Dividing Lines No
-Auto Center Yes
-Pop Up Yes
-Modal Yes
-Border Style Thin
-Control Box No
-Min Max Buttons None
-Close Button No
-Shortcut Menu No
Name the form frmPassword.
Add a text box called txtPassword with an Input Mask
of "Password" (without the quotations).
Add a label called lblPassword and have the caption say
something like "Please Enter Administrator Password."
Add a command button called cmdCloseForm that simply
closes the form; nothing else in that code.
Add another command button called cmdShowAdminArea and
code it like the following:
'Code Start
Private Sub cmdShowAdminArea_Click()
On Error GoTo ErrorHandler
If Me.txtPassword <> "password" Then
' Substitute with your own password
MsgBox "Incorrect Password",
vbExclamation, "Access Denied"
DoCmd.Close acForm, "frmPassword"
Else
Forms!Switchboard.Filter = "[ItemNumber] = 0 And
[SwitchboardID] = 2"
Forms!Switchboard.Refresh
DoCmd.Close acForm, "frmPassword"
End If
ExitPoint:
Exit Sub
ErrorHandler:
MsgBox Err.Description
Resume ExitPoint
End Sub
' Code End
Please watch out for some line wrapping in that code!!
This assumes that the Admin Switchboard area you want to
protect is number "2" in the Switchboard Items TABLE. Make
sure to change that number to whatever matches your table
value. This also assumes that the NAME of your switchboard
form is actually just "Switchboard." Change the code if
you have changed the name. Dress up the message box with
whatever formatting and/or message you desire.
Use the Switchboard Manager Wizard to create the entry to
go to this Admin area. Instead of using the option that
opens up a Switchboard, make it open the frmPassword
instead. Like this:
Edit Switchbaord Item:
Text: Go To Admin Area
Command: Open Form In Add Mode
Form: frmPassword
Now when the person clicks on the Switcboard option that
says "Go To Admin Area" the Password form opens up on top.
Unless they enter the correct password, the Switchboard
will not change to show the Admin menu. It would also be a
good idea to hide the Database Window from the users.
Hope that helps,
Jeff Conrad
Bend, Oregon