Page 1 of 3 123 LastLast
Results 1 to 15 of 31
  1. #1
    Join Date
    Jul 2013
    Posts
    46

    Unanswered: Multiple Passwords To Protect a Form

    I have the following code to protect forms. Is there a way to have more than one password to open a form?



    Private Sub Form_Open(Cancel As Integer)
    Dim PassWord As String

    PassWord = InputBox("Enter Password")
    Cancel = (PassWord <> "password")


    If Cancel Then MsgBox ("You are not authorized for access.")
    End Sub


    Thank you,
    Bill

  2. #2
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Using the same method?

    Cancel = (PassWord <> "password" And PassWord <> "whatever")
    Paul

  3. #3
    Join Date
    Jul 2013
    Posts
    46
    Thank you very much Paul. I just couldn't get that to work before.

  4. #4
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    No problem. The most common mistake is using Or instead of And, which seems like what you would want. Using <> instead of = reverses the logic though, making And the correct choice.
    Paul

  5. #5
    Join Date
    Jul 2013
    Posts
    46
    Exactly what I was trying to do. Thanks again!!!

  6. #6
    Join Date
    Jul 2013
    Posts
    46

    Password Protect Forms

    I have come up with an idea to be able to change passwords so that it will affect all of my forms so I won't have to change the code for each form individually. I created a table Passwords. I also created a form Passwords to change the passwords.

    How can I alter my previous code so the forms will reflect the password changes?



    Private Sub Form_Open(Cancel As Integer)
    Dim PassWord As String

    PassWord = InputBox("Enter Password")
    Cancel = (PassWord <> "Houston")

    If Cancel Then MsgBox ("You are not authorized for access.")
    End Sub



    Thanks,
    Bill
    Attached Thumbnails Attached Thumbnails Passwords Table.png   Passwords Form.png  

  7. #7
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    there is, in my books a better idea
    assign users to workgroups
    when your form or report loads test whether the user has the correct permissions. in this case what you actually do is check the user is a member of the usergroup that you have defined as required for this form or report
    say its an HR system you coudl have a form which is for HR personnel only, another for managers and HR
    so you know the form is, say for HR only, so check the current user is a member of the HR workgroup. if they are allow the form to load, if not force the load to cancel
    in tyhe workgroup model a user can be a member of many workgroups. to be hoinest im not to sure what has repalced the workgroup model in a2007 on. but there shoudl be an equivalent process

    for preference don't user the current user function instead use the network logon. when somebody needs to use the access app add their network logon to the workgroup file with appropriate permisssions

    this way round you are not hardcoding passwords (if you use the netowrk logon api call then you dont' have to handle passwords at all. you dont' force users to have yet another f)(*&)(*&g password to remember. you dont' have to worry about people moving or leaving and retaining the logon (after all your network trolls should de list the account so they ex employee can no longer use the system
    I'd rather be riding on the Tiger 800 or the Norton

  8. #8
    Join Date
    Jul 2013
    Posts
    46
    I have version 2013 and there are no workgroups or users. I have a main switchboard with buttons to open various forms. I sectioned off Users that everyone can get to and Administrators with different passwords for different forms.

  9. #9
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    You can use a DLookup() to find the security level associated with a password. Null will be returned if a password was entered that doesn't exist.
    Paul

  10. #10
    Join Date
    Jul 2013
    Posts
    46
    Private Sub Form_Open(Cancel As Integer)
    Dim PassWord As String

    PassWord = InputBox("Enter Password")
    Cancel = (PassWord <> Dlookup Forms!Passwords, Level 1, password)

    If Cancel Then MsgBox ("You are not authorized for access.")
    End Sub

    Is this correct to enable Level 1 asking for Houston?

  11. #11
    Join Date
    Jul 2013
    Posts
    46
    Am I closer with this?

    Cancel = (PassWord <> DLookUp("[SecurityLevel]"="Level 1","Passwords")

  12. #12
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Closer anyway.

    http://www.mvps.org/access/general/gen0018.htm

    Are your passwords intended to be form-specific, or levels (like a level 1 can see anything)?
    Paul

  13. #13
    Join Date
    Jul 2013
    Posts
    46
    Yes Level 1 can see everything. Then the different levels will have certain permissions.

  14. #14
    Join Date
    Jul 2013
    Posts
    46
    This one seems like the closest one to use:

    DLookup("FieldName", "TableName", "Criteria = '" & forms!FormName!ControlName & "'")

    I just can't apply the logic for when levels change to ask for that level's password.

  15. #15
    Join Date
    Jul 2013
    Posts
    46
    Is this dependent on the record ID for the levels?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •