• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1476
  • Last Modified:

Password Protecting a Menu Option in MS-Access 2010

I have a switchboard menu (see attached, Main Menu.jpg). What I would like to do is to make the second option in the menu, i.e., Graduation Application, password protected, so that if a user clicks on the option, a prompt will appear asking him/her to enter the password. If the user enters the password successfully, then they will be allowed to continue (in this case, they will proceed to the "View, Edit, Import Records or Print Applications" menu (see Switchboard Items.jpg). If they fail to enter the correct password, they will remain at the same menu. I have also attached the code for the SwitchBoard (SwitchBoard_Code1.jpg and SwitchBoard_Code2.jpg).

What would be the easiest way to go about this? Should I use a form or an inputbox?

Thanks.
Main-Menu.jpg
Switchboard-Items.jpg
SwitchBoard-Code1.jpg
SwitchBoard-Code2.jpg
1
geeta_m9
Asked:
geeta_m9
  • 4
  • 3
1 Solution
 
Eric ShermanAccountant/DeveloperCommented:
I have a Access application where I created that functionality using a password prompt form.  I will review your samples and respond shortly.

ET
0
 
geeta_m9Author Commented:
Thanks.
0
 
Eric ShermanAccountant/DeveloperCommented:
Ok, here's how I implemented a password prompt to control menu items on a Access form.  Your layout is a bit different in that you are not opening up forms ... seems like you are opening a table.  The concept should be the same.  If you can't adapt it then just load up a sample of your database so I can review further.

1.) Create a one record table called SetupGeneral with a Text field named PSWD.  Then enter the password in this field.

2.)  Create a small Form named frmPSWDPrompt with a Unbound field name TxtPSWD, OK button and Cancel Button (see my sample picture).
Password Prompt Form
3.)  See VBA Code below for the various OnClick Events that will open the Password Prompt Form where the user can enter a valid password to continue.
'USE THIS CODE FOR THE ON CLICK EVENT OF THE MENU ITEM YOU WANT TO PASSWORD PROTECT.
Private Sub Command151_Click()
     DoCmd.OpenForm "frmPswdPrompt", , , , , acDialog
End Sub


'USE THIS CODE FOR THE ON CLICK EVENT OF THE OK BUTTON ON THE PASSWORD PROMPT FORM.
Private Sub Command_OK_Click()
If IsNull(Me.TxtPSWD) Then
    MsgBox "Password cannot be blank!!!!!", vbCritical, ""
    Exit Sub
ElseIf Me.TxtPSWD <> DLookup("[PSWD]", "SetupGeneral") Then
    MsgBox "Please enter a valid password!!!!!", vbCritical, ""
    Me.TxtPSWD = Null
    Exit Sub
Else
    DoCmd.OpenForm "Your Form Name Here", acNormal
    DoCmd.Close acForm, "frmPSWDPrompt"
End If
End Sub


'USE THIS CODE FOR THE ON CLICK EVENT OF THE CANCEL BUTTON ON THE PASSWORK PROMPT FORM.
Private Sub Command_Cancel_Click()
DoCmd.Close acForm, "frmPSWDPrompt"
End Sub

Open in new window



ET
0
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 
geeta_m9Author Commented:
My situation is a little different because of the switchboard. I am not sure where to put the VBA code.

I am attaching a copy of the database.
GraduationApplication-August2012.accdb
0
 
Eric ShermanAccountant/DeveloperCommented:
<<<<<My situation is a little different because of the switchboard. I am not sure where to put the VBA code.>>>>>

Yes, and I've looked at your db ... you are using embedded macros and my solution assumed you were using VBA events.  Although it probably works for you, the macros seems a bit confusing for me to navigate and follow.  I would have just used Combo Boxes on the main form to present the user with various selections.  Then using the After Update Event, either Enable or Disable the relative selection box.

Maybe another Expert who works with embedded macros can provide something that will work with what you already have.

ET
0
 
geeta_m9Author Commented:
I tried the code that you gave, and it works well. The only problem I am facing now is that I am unable to go down to the next level of the menu if the user enters the password correctly... it is still stuck at the same menu level. The switchboard menu was created using macros, and I don't know how to write the code (or  the macro) to make it go down to the next level of the menu.

It looks as though I may have to redesign my menu to use the code builder (VBA) instead of macros, if I want to make the option password protected.

Anyway, I appreciate your help.
0
 
Eric ShermanAccountant/DeveloperCommented:
Thanks for the points ...  I would use Combo Box Controls and Forms Objects to present the user with a menu selection.  If the password is entered correctly, you can either open the Form or Enable a Control, etc.

ET
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now