Cancelling vb action

A

AWM

I have created the following code that is executed at the OnClick event
of a command button:

--------------------
Private Sub Command56_Click()

DoCmd.OutputTo acOutputQuery, "qry_CADDWGLog_Export", acFormatXLS

Exit_Command56_Click:
Exit Sub

Err_Command56_Click:
MsgBox Err.Description
Resume Exit_Command56_Click

End Sub

--------------------
The code works great except if the operator cancels the download
OutputTo action. When the action is cancelled, a dialog box appears
stating...

Run-time error 2501

The OutputTo action was cancelled.

<End> <Debug> <Help>

I want to avoid the opportunity for the operator to click <debug> and
thereby enter the VB environment.

Any recommendations? Thanks. Art
 
K

Ken Snell [MVP]

You need to insert an error handler statement:


Private Sub Command56_Click()
On Error GoTo Err_Command56_Click
DoCmd.OutputTo acOutputQuery, "qry_CADDWGLog_Export", acFormatXLS

Exit_Command56_Click:
Exit Sub

Err_Command56_Click:
MsgBox Err.Description
Resume Exit_Command56_Click

End Sub
 
T

Todd Shillam

You can disable the ability for application users to debug by changing some
of the startup options.

Tools>Startup>...

Look for 'Use Special Access Keys' and disable--that should prevent users
from debugging. Take a look around at some of the startup options while you
are there.


Todd
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top