RunCommand Canceled error

M

magmike

I set up a button control to start the import process:

Private Sub ImportData_Click()
DoCmd.RunCommand acCmdImport
End Sub

However, when "Cancel" is selected from the resulting file selection
box, I receive an error from the database:

Run-time error '2501':

The RunCommand action was canceled.

How can I fix this?

thanks,
magmike
 
S

Stuart McCall

magmike said:
I set up a button control to start the import process:

Private Sub ImportData_Click()
DoCmd.RunCommand acCmdImport
End Sub

However, when "Cancel" is selected from the resulting file selection
box, I receive an error from the database:

Run-time error '2501':

The RunCommand action was canceled.

How can I fix this?

thanks,
magmike

Insert the following line right before the DoCmd line:

On Error Resume Next

That tells Access to ignore all errors until the procedure ends.
 
D

Dennis

Either an OnError statement or SetWarnings Off.

The message you're getting is normal when you cancel the operation.
 
M

magmike

Insert the following line right before the DoCmd line:

On Error Resume Next

That tells Access to ignore all errors until the procedure ends.- Hide quoted text -

- Show quoted text -

Thanks! (to both of you)
 

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