I use the Click event of a label on a form to execute a parameter query. If I choose cancel in the parameter dialog box I get error 2001, You canceled the previous operation. How can I capture this error so it does not display? I tried a Select Case statement in various places to no avail.
Private Sub Label10_Click()
Dim strMessage As String
Dim DataErr As Integer, Response As Integer
Dim bytChoice As Byte
On Error GoTo Label10_Click_Error
DoCmd.SetWarnings False
strMessage = “If the first step did not result in a report of sold assets, ” _
& “this step may be skipped! Select Cancel” & vbCrLf & vbCrLf _
& ” ” & “Else, choose OK to proceed to remove the sold Asset.”
bytChoice = MsgBox(strMessage, vbOKCancel + vbExclamation, “Please Read”)
If bytChoice = vbCancel Then
DoCmd.CancelEvent
ElseIf bytChoice = vbOK Then
DoCmd.OpenQuery “qry_REMOVE_ASSET_FROM_PRECHECK_TO_AO”
DoCmd.SetWarnings True
End If
Label10_Click_Error:
‘Exit Sub
Select Case DataErr
Case 2001
Exit Sub
Case Else
Response = acDataErrDisplay
End Select
MsgBox “Error ” & Err.Number
End Sub