Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2009
    Posts
    4

    Unanswered: Password on a form

    I am trying to secure one of my forms so that only nurses can access it and edit it. I used the code found here...

    Private Sub Form_Open(Cancel As Integer)

    Dim pwd As String
    pwd = InputBox("Enter the Password")
    If pwd = "Your Password here" Then
    MsgBox "Password Correct"
    Else
    MsgBox "Incorrect Password!!"
    DoCmd.Close
    End If

    End Sub


    ...which works but the only problem is that nurses will be opening this form up multiple times in a session and I don't want them to enter the password everytime. Is there something that I can add to this code where they only have to enter it once during the time that they have the database open.

    TIA

  2. #2
    Join Date
    Apr 2004
    Location
    Kingsland, Georgia
    Posts
    231
    global variable in a module that you set to true when they enter the password correctly? then in the form load, you can run your code if the variable is set to false.

    I'd check out really implementing access security, though. If you're trying to keep out all non-nurses, any non-nurse can hit Alt-F11 and see the password in the code.

    access security would allow you to create a user group for Nurses, assign those users that you want, and only allow that group to open the form.

  3. #3
    Join Date
    Apr 2009
    Posts
    4
    Thanks for your reply.

    I have another question about setting up a secured database. The program is currently in Access 2003 but in the next few months they are switching over to 2007. Will the security workgroup still work if I add that piece to my database? I would rather do that so that I can give certain people views of the data without the ability to edit.

    TIA

  4. #4
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Yes, but don't update the database from an MDB/MDE to the ACCDB/ACCDE format or all user-level security will be stripped away from it.

    I'd actually suggest the GetUser() thing in the code bank as a solution for this... provided each user has their own windows login. Then the users don't have to enter a single password.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

Posting Permissions

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