Results 1 to 3 of 3
  1. #1
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Jacksonville,NC, USA
    Posts
    705
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Creating dual login (Access 2003)

    Good afternoon everyone!
    I have a piece of code that I am pasting below. This code is placed on a command buttons on-click event to allow users to access a form based on the user having the correct password. In a database that is being constructed, (it's huge) I am also using the same code (with edited changes for form names and passwords) to allow 18 different divisions to access their unique form made just for them with their own unique passwords for entry. The form they gain access to has macros that open all there queries, reports, and forms built just for their divisional needs.

    At this time Admin can get in because I've enabled a bypasskey module and admin control so they can enter anywhere anyway, but I am still wondering (for the heck of it), is there a way to add another IF statement in this piece of code or an OR statement within the existing codes IF statement that would allow the admin person (the one who will be fixing and troubleshooting) access to each individuals form without having to memorize 18 different divisions passwords should they be sitting at the persons desk and just want to open the form for viewing?

    Eg. I am with Division G16 and my password is "456ABC!" and I am not in my office but Admin wants to look at my form. Could Admin also enter their password of "TH112FORGE" to enter the same form as well?

    Appreciate the feedback

    '**********************'
    Type Form Name on next line, eg. cmdOpenEmployeeForm_Click()
    Private Sub cmdOpenWhateverForm_Click()

    'Attached to On Click event of cmdOpenWhateverForm

    Dim strPasswd

    strPasswd = InputBox("Enter Password", "Restricted Form")

    'Check to see if there is any entry made to input box, or if
    'cancel button is pressed. If no entry made then exit sub.

    If strPasswd = "" Or strPasswd = Empty Then
    MsgBox "No Input Provided", vbInformation, "Required Data"
    Exit Sub
    End If

    'If correct password is entered open Employees form
    'If incorrect password entered give message and exit sub
    'Enter Password on next line

    If strPasswd = "admin" Then
    DoCmd.OpenForm "frmEmployeeForm", acNormal
    Else
    MsgBox "Sorry, you do not have access to this form", _
    vbOKOnly,"Important Information"
    Exit Sub
    End If

    End Sub
    '************************
    NMP <img src=/S/cool.gif border=0 alt=cool width=15 height=15>

    If you can't convince them, confuse them. - Harry Truman <img src=/S/scratch.gif border=0 alt=scratch width=25 height=29>

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Creating dual login (Access 2003)

    For Division G16, I assume that the line
    <code>
    If strPasswd = "admin" Then
    </code>
    will actually be
    <code>
    If strPasswd = "456ABC!" Then
    </code>
    You could change this to
    <code>
    If strPasswd = "456ABC!" Or strPassword = "TH112FORGE" Then
    </code>
    Or perhaps I haven't understood the setup correctly.

  3. #3
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Jacksonville,NC, USA
    Posts
    705
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Creating dual login (Access 2003)

    Hans

    Thank you. I messed up with my practicing by forgetting the extra command of ' strPasswd = ' before my second choice. I had used the OR while waiting for your response so it looked like:

    If strPasswd = "456ABC!" Or "TH112FORGE" Then


    The corrected line you gave me looks like:
    If strPasswd = "456ABC!" Or strPasswd = "TH112FORGE" Then

    It works beautifully now. Thank you thank you thankyou
    As always <img src=/S/smile.gif border=0 alt=smile width=15 height=15>
    NMP <img src=/S/cool.gif border=0 alt=cool width=15 height=15>

    If you can't convince them, confuse them. - Harry Truman <img src=/S/scratch.gif border=0 alt=scratch width=25 height=29>

Posting Permissions

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