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

How to create a password for access forms

Hello,
I have created the password for the form, as directed by the experts here, but i have to create another password for the form, that has "add material number". I have attached the database for u, if you can open the database, the main menu appears and pops up a password dialog box, I need exactly same asking for a pasword the user clicks the "add material menu". In my database, a password box should appear as it appears for the "main menu". can you please give a suggestion. Thanks

X-BAR-2009--TEST-1.mdb
0
jpeterjeyaraj
Asked:
jpeterjeyaraj
  • 4
  • 2
4 Solutions
 
Surone1Commented:
each form requests the password for its form name.

so go into tblpassword and add an entry for :
[objectname]                           [keycode]
ADD NEW MATERIAL MENU       whateveryouwantthepasswordtobe
0
 
Surone1Commented:
if you add this code to any other forms you would need to add those to tblpassword as well.
0
 
jpeterjeyarajAuthor Commented:
can you please detail me about this still its give me a error message. I added one column as add material menu in table password and keycode as 1234. should I also create a form password fo this add material menu? Please advise me, thanks
0
Independent Software Vendors: 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!

 
Surone1Commented:
ok. it seems the password code was not working for me so i changed it.

anyway first open main menu form in design view and rigtclick the "ADD NEW MATERIAL NUMBER" button and choose properties.
under the events tab doubleclick in the emy text behind onclick (so it says [event procedure]) and then click the button behind it.

insert the code to open the form:

Private Sub ADD_NEW_MATERIAL_NUMBER_Click()
 DoCmd.OpenForm "ADD NEW MATERIAL MENU"
 End Sub

then open the "add new material menu" form and in the properties window under events doubleclick behind the "on open" event. i changed the on open code to:

Private Sub Form_Open(Cancel As Integer)
   Dim Hold As Variant
   Dim tmpKey As Long
   Dim I As Integer
   Dim rs As DAO.Recordset
   Dim db As DAO.Database

   On Error GoTo Error_Handler
   ' Prompt the user for the Password.
   DoCmd.OpenForm "frmPassword", acNormal, , , , acDialog
            Hold = MyPassword
' Open the table that contains the password.
   Set db = CurrentDb
   Set rs = db.OpenRecordset("tblPassword", dbOpenTable)
   rs.Index = "PrimaryKey"
   rs.Seek "=", Me.Name
   If rs.NoMatch Then
      MsgBox "Sorry cannot find password information. Try Again"
      Cancel = -1
   Else
      ' Test to see if the key generated matches the key in
      ' the table; if there is not a match, stop the form
      ' from opening.
      If Not (rs![keycode] = CStr(Hold)) Then
 ' above line was changed from :     If Not (rs![keycode] = keycode(CStr(Hold))) Then
         MsgBox "Sorry you entered the wrong password." & _
            "Try again.", vbOKOnly, "Incorrect Password"
         Cancel = -1
      End If
   End If
   rs.Close
   db.Close
   Exit Sub

Error_Handler:
   MsgBox Err.DESCRIPTION, vbOKOnly, "Error #" & Err.Number
   Exit Sub
End Sub



0
 
Surone1Commented:
visual aid
matmenu.jpg
0
 
jpeterjeyarajAuthor Commented:
How can i give a password of my choice, any advice please. and also if you open the above database, if you open for the first time, it asks for passowrd and then if you open the main menu it asks for password or If I close the password form I can able to access even though if I dont enter the password.Any suggestion how to rectify this problem. Thanks,
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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