Error 2501 and parameter Queries

cybhunter

Registered User.
Local time
Today, 14:22
Joined
Sep 11, 2007
Messages
17
Hello,

I have a form based on a parameter query. The form is launched via a command button from another form with vba code. When I click to "Choose Report" (my command button) I am prompted to enter a report numer. If I enter an ID all is happy -- if I click cancel w/o entering anything I get a runtime error 2501 -- The OpenForm operation was cancelled. It works if I click OK w/o any data. The problem is when I click CANCEL.

Does anyone know how to handle this error?

Code:

Private Sub Command2600_Click()
On Error GoTo ErrHandler
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmSearchForMainList"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exithere:
Exit Sub

ErrHandler:
Select Case Err.Number
Case 2501
Resume exithere
Case Else
MsgBox Err.Number & " - " & Err.Description
Resume exithere
End Select
End Sub


Thank you,
Kurt
 

Users who are viewing this thread

Back
Top Bottom