command button

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

If when I run a macro that involves opening a query that has a parameter
value to be entered and I press the cacel button on the parameter input box,
how do i prevent the message the tells me the macro is being halted.

Once i press cancel i just want to go back to the form,

or can this be done in code?
--
Regards



Patrick Stubbin
 
If when I run a macro that involves opening a query that has a parameter
value to be entered and I press the cacel button on the parameter input box,
how do i prevent the message the tells me the macro is being halted.

Once i press cancel i just want to go back to the form,

or can this be done in code?

One of the problems using Access Macros is that there is no error
handling. You have to trap error 2501.
Use code to open the query.

Sub CommandButton_Click()
On Error Goto Err_Handler

DoCmd.OpenQuery "QueryName"

Exit_Sub:
Exit Sub

Err_Handler:
If Err = 2501 Then
Else
MsgBox "Error #: " & Err.Number & " " & Err.Description
End If
Resume Exit_Sub
 
Back
Top