Error 2001 operation cancelled by user

CJBIRKIN

Drink!
Local time
Today, 02:34
Joined
May 10, 2002
Messages
256
Hello
I have a report that uses 2 different queries depending on a selection by the user. I am using the recordsource property in a module. However both queries contain input boxes (I've designed the queries in the QBE). The problem is if the user selects one of the queries and then selects cancel instaed of entering data into the input box the program commes up with error 2001 saying the user cancelled the operation. Is it possible to exit the formload procedure if this occurs

Cheers Chris
 
Make sure that you have some error trapping in your code
eg

Sub YourCode()

On Error Goto ErrorHandler

Rest of your code
including openReport/Form command

ExitCode:
Exit Sub

ErrorHandler:
Select Case err.Number

Case 2001
MsgBox "Operation Cancelled"
goto ExitCode

Case Else
msgbox err.number & " " & err.description
End Select
End Sub
 
Hello
I tried to add some error handling at the time:

Private Sub Form_Load()

If openargs = "QRY_SELECT_REQUEST_BY_ID" Then
REQUESTER_ID_Label.Visible = False
[REQUESTER ID].Visible = False
End If

On Error GoTo cancelsub
Forms!FRM_SELECT_CLIENT.RecordSource = openargs
cancelsub:

If Err = 2001 Then

AND HERES THE BIT I COULDN'T WORK OUT
I WANT TO UNLOAD/CLOSE THE FORM BUT ITS NOT YET OPEN. EVEN IF I TRAP THE ERROR THE FORM STILL OPENS WITH ALL THE BOXES SHOWING name#.
IT JUST DON'T LOOK PRETTY.
ANY IDEAS????
End If
End Sub

Cheers Chris
 

Users who are viewing this thread

Back
Top Bottom