Results 1 to 5 of 5
  1. #1
    PinkLady50 is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2017
    Posts
    171

    Password logic not working on Event Procedure

    I have an existing database that is working fine. I took of copy of the database and made some enhancements with the addition of some tbls, queries and forms. I used the database copy to test out using a Password. It worked perfectly. This weekend I moved all my new objects (tbls, queries and forms) into the existing database. Everything came over fine.



    I copied the password event procedure and put it in the same place but it is not recognizing it when I click on the form. I am not sure what to check next.

    Code:
    Private Sub Page84_Click()
    Dim PassWord As String
     If PassWord = "Superman" Then
       DoCmd.OpenForm "Page84"
     Else
        MsgBox ("Access Denied")
     End If
    End Sub

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    You haven't asked the user to enter a password. Check out InputBox(), or use a form.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    A word of warning - never use passwords. There are millions of files out there which can never be accessed due to there being a password which no one knows any more. A far better way is the check the user login ID and have a table restricting the use of the database to those. Also, having the password hardcoded in VBA can so easily be hacked.

    What is the exact error? How can the password contain anything when you define it in the line above? It will always be null.

  4. #4
    PinkLady50 is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2017
    Posts
    171
    I moved the code to the Form_Open and it worked.

    Thanks again.

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    The same code? I don't see how that's possible. That code would always return the message box.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Event Procedure not working in Access 2010
    By catguy in forum Programming
    Replies: 3
    Last Post: 11-22-2014, 07:59 AM
  2. Replies: 1
    Last Post: 03-29-2014, 07:46 PM
  3. Replies: 2
    Last Post: 01-15-2014, 07:57 PM
  4. Replies: 3
    Last Post: 05-07-2012, 12:17 PM
  5. Replies: 5
    Last Post: 10-26-2011, 02:59 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums