Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2005
    Posts
    10

    Unanswered: SwitchBoard Query problem using Macros

    Hi Guys,
    I have a switchboard using the OpenQuery macro to open a parameter query. It works well, except when a user pushes the cancel button on the pop-up screen prompting for the parameter value. We then receive a "Action Failed" box. How do i correct this problem?. Thanks in advance for your replies.

  2. #2
    Join Date
    May 2010
    Posts
    601
    Quote Originally Posted by maypen View Post
    Hi Guys,
    I have a switchboard using the OpenQuery macro to open a parameter query. It works well, except when a user pushes the cancel button on the pop-up screen prompting for the parameter value. We then receive a "Action Failed" box. How do i correct this problem?. Thanks in advance for your replies.
    What version of Access are you using?

    You will need to add error handling to trap error 2501.

    The reason I normally never use macros is because of the lack of error handling. In Access 2007, then macros have improved.


    example for a Save command button:

    Code:
    Private Sub cmdSave_Click()
    On Error GoTo Err_cmdSave_Click
    
    
        If Me.Dirty Then
           Me.Dirty = False
        End If
    
    
        Me.CloseButton = True
        Me.AllowEdits = False
    
    Exit_cmdSave_Click:
        Exit Sub
    
    Err_cmdSave_Click:
    
      ' check to see if the Before Update event cancelled the save
        If Err.Number <> 2501 Then
            MsgBox Err.Description
        End If
        Resume Exit_cmdSave_Click
        
    End Sub

    I would also urge you to use a form to display data to a user, not a query. You can use the form to collect the parameters and do data validation.
    Last edited by HiTechCoach; 05-05-10 at 12:19.
    Boyd Trimmell aka HiTechCoach HiTechCoach.com (free access stuff)
    Microsoft MVP - Access Expert
    BPM/Accounting Systems/Inventory Control/CRM
    Programming: Nine different ways to do it right, a thousand ways to do it wrong.
    Binary--it's as easy as 1-10-11

  3. #3
    Join Date
    Dec 2005
    Posts
    10
    Thanks for replying. I will give your code a try. I am using Access 2007 but in 2002 mode.

Posting Permissions

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