Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2002

    Unanswered: OpenForm Method was Cancelled promblem.

    I am coding in access 97. I am a newbie to coding the front side in access. My problem is that I have a form name frmSearch. This form is bound to a query that uses a prompt in the criteria area. So when frmSearch is called the prompt is displayed. I have a button on my main form that when it is clicked the frmSearch form is opened. Thus displaying the prompt. If the user clicks cancel on the prompt I receive this message stating that the "OpenForm method was cancelled". How do I avoid getting this message. When cancelling the prompt.

  2. #2
    Join Date
    Nov 2001

    Here is an example:

    Private Sub cmdSearch_Click()

    On Error GoTo Error_cmdSearch_Click

    DoCmd.OpenForm "frmSearch", , , , , acDialog

    Exit Sub

    Select Case Err.Number
    Case 2501
    ' you get here when the openform method was canceled.
    Resume Exit_cmdSearch_Click
    Case Else
    MsgBox Err.Description, vbCritical, "Error: " & Err.Number
    Resume Exit_cmdSearch_Click
    End Select

    End Sub

    Of course, you can develop more sophisticated error handler. But this simple is enough in many cases.


Posting Permissions

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