Results 1 to 6 of 6
  1. #1
    Oxygen Potassium is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2016
    Posts
    40

    Password Protected Form Won't Open New Form on Error


    I have a form called "Maintenance" that when opened asks the user to provide a password. This part works well. The problem I have is when I get an error (the wrong password is entered) I want to go back to the previous form called "Navigation". This is the part that doesn't quite work. The message box populates telling me "Wrong Password" but the "Navigation" form never opens. Appreciate any help on this.

    Code:
    Private Sub Form_Open(Cancel As Integer)
    On Error GoTo Error_Handler
     
        If StrComp(InputBox("Please enter the Password"), "Password", 0) <> 0 Then
            Cancel = True
            MsgBox "Wrong password.", vbInformation Or vbOKOnly, "Operation cancelled"
        End If
        
    Exit_Maintenance_form:
        DoCmd.OpenForm "Navigation"
        Exit Sub
        
    Error_Handler:
    Resume Exit_Maintenance_form
    
    
    End Sub

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,820
    Have you step debugged? Does the Exit block run? I doubt the error handler runs because there is no runtime error.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Oxygen Potassium is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2016
    Posts
    40
    The Exit block does run (closes the Maintenance form) but the Navigation form doesn't populates

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,820
    I did a quick test with my db and the other form opens.
    It even opens if password is correct and then both forms are open.

    However, the input box runs twice.

    If you want to provide db for analysis, follow instructions at bottom of my post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Is this a built in navigation form you're trying to load, or something you created? Be that as it may, I don't see the logic in that code because it doesn't matter what the result is - the call to open the navigation form will run anyway.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  6. #6
    Oxygen Potassium is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2016
    Posts
    40
    Thanks guys I was actually able to play around with the Events on both pages to achieve what I was trying to accomplish here.

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

Similar Threads

  1. Open Password Protected DB with VBA
    By Oxygen Potassium in forum Access
    Replies: 12
    Last Post: 11-04-2016, 09:20 AM
  2. Replies: 2
    Last Post: 05-05-2015, 02:13 PM
  3. Password protected form or report
    By mar_t in forum Access
    Replies: 11
    Last Post: 06-20-2013, 05:52 AM
  4. Creating a password protected FORM
    By KingOf206 in forum Forms
    Replies: 5
    Last Post: 04-16-2013, 02:21 PM
  5. Open a password protected MDB/MDW
    By abcc14 in forum Security
    Replies: 8
    Last Post: 11-02-2011, 07:41 AM

Tags for this Thread

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