RunCommand Canceled error

  • Thread starter Thread starter magmike
  • Start date Start date
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
 
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.
 
Either an OnError statement or SetWarnings Off.

The message you're getting is normal when you cancel the operation.
 
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)
 
Back
Top