Results 1 to 3 of 3
  1. #1
    LoveLearning is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2012
    Posts
    4

    If no matches Reopen form after Msgbox

    Hi,

    I currently have an unbound form I am using as a switchboard. When a button is pressed it loads a form asking for the user to enter their password (the swtichboard is then closed). If the correct password is entered the form opens to their details, when that form is closed, the swtichboard re-opens. I want an action that if the correct password is not used, then a msgbox lets them know and then the Switchboard they were at re-opens. So far I have the following code:
    Private Sub Form_Open(Cancel As Integer)
    If Me.Recordset.RecordCount = 0 Then
    MsgBox "Incorrect Password!"
    Cancel = True
    End If
    End Sub



    This works well, but I am unsure how to write that after the msgbox I want the Switchboard to open. I tried to add "DoCmd.OpenForm frmSwitchMain" in various places, but I am unsure on the proper proceedure to do this.

  2. #2
    Rawb is offline Expert
    Windows XP Access 2000
    Join Date
    Dec 2009
    Location
    Somewhere
    Posts
    875
    You would add it immediately after your MsgBox and before "Cancel = True".

    Code:
    Private Sub Form_Open(Cancel As Integer)
      If Me.Recordset.RecordCount = 0 Then
        MsgBox "Incorrect Password!"
        DoCmd.OpenForm "frmSwitchMain"
        Cancel = True
      End If
    End Sub

  3. #3
    LoveLearning is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2012
    Posts
    4
    This is Perfect...Thank you so much for your effort.

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

Similar Threads

  1. Replies: 3
    Last Post: 06-22-2012, 04:19 PM
  2. Replies: 2
    Last Post: 06-01-2012, 08:10 AM
  3. Replies: 9
    Last Post: 03-29-2011, 07:08 PM
  4. Replies: 2
    Last Post: 03-14-2011, 03:42 PM
  5. Replies: 1
    Last Post: 05-18-2010, 12:05 PM

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