password protecting a form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SeadooRider
    New Member
    • Jan 2013
    • 48

    password protecting a form

    The following code on form_load does ask for a password and opens the desired form if the password is entered correctly. However, if no password or the incorrect password is entered, I get the message box stating the user does not have access to the desired form but then it opens that form anyway.

    Please advise,
    Jason

    Code:
    Dim PassWord As String
    If PassWord - admin1234" Then
    doCmd.openForm "frmAdminMenu"
    Else
    MsgBox ("Access Denied")
    End If
    End Sub
  • Seth Schrock
    Recognized Expert Specialist
    • Dec 2010
    • 2965

    #2
    You would need to either put this in the form's OnOpen event so that you can cancel the opening of the form if the password is wrong, or put this in the button that opens the form. Basically what is happening is that you are opening the form and then testing. However, there is nothing to cancel the forms opening so the form will still open.

    Comment

    • SeadooRider
      New Member
      • Jan 2013
      • 48

      #3
      Thanks, I put it in the button that opens the form and all works as expected.

      Comment

      • Seth Schrock
        Recognized Expert Specialist
        • Dec 2010
        • 2965

        #4
        Just be aware that if the user has access to all the database objects, they can open the form directly and bypass the password requirement.

        Comment

        • SeadooRider
          New Member
          • Jan 2013
          • 48

          #5
          Yes, I plan on locking that down once I'm complete with the build. Which leads me to my next question, is there a way for the user to change the password without going into the code if need be?

          thx
          Jason

          Comment

          • Seth Schrock
            Recognized Expert Specialist
            • Dec 2010
            • 2965

            #6
            There would be a way to do that (with a few design changes), but since that is a different question than the original, it needs to go in a new thread. We will be glad to help you there.

            Comment

            Working...