Results 1 to 2 of 2
  1. #1
    2 Star Lounger
    Join Date
    Mar 2002
    Posts
    164
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Run-time error 2501 (2003)

    I have a form which passes values to another form to pull up a specific owners record. On the first form which passes the values I have the following code for the OK and Cancel buttons...

    Private Sub Command3_Click()
    Me.Visible = False
    DoCmd.OpenForm "Owner Information", acViewNormal, acEdit
    DoCmd.Close acForm, "Owner Search"
    End Sub

    Private Sub Command4_Click()
    DoCmd.Close 'Close Form
    End Sub

    The code works perfectly and it displays the record if one is found. But if a record is not found, I have a popup returned from the following code...

    Private Sub Form_Open(Cancel As Integer)
    If Me.RecordsetClone.RecordCount = 0 Then
    MsgBox "No results returned, please try again.", vbInformation
    Cancel = True
    End If
    End Sub

    Unfortunately, I get a run-timer error '2501' which reads The OpenForm action was cancelled. Any ideas? I have a feeling it deals with the open and close of the second form, but not certain. Any help is much appreciated. Thanks in advance.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Run-time error 2501 (2003)

    It is usually safe to ignore error 2501:

    Private Sub Command3_Click()
    On Error GoTo ErrHandler

    Me.Visible = False
    DoCmd.OpenForm "Owner Information", acViewNormal, acEdit
    DoCmd.Close acForm, "Owner Search"

    ExitHandler:
    Exit Sub

    ErrHandler:
    If Err = 2501 Then
    ' Action canceled - ignore
    Else
    ' Display error message
    MsgBox Err.Description, vbExclamation
    End If
    Resume ExitHandler
    End Sub

Posting Permissions

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