Suppressing Error Message

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

Guest

I use an Access form that has a button that when you click runs a query. When
I click on the button and hit cancel. I get the a box with the following
message. Run time error '2001' you cancelled the previous operation. when you
hit debug it takes me to the following code.

Private Sub Command21_Enter()
DoCmd.OpenQuery "Daily scanned", vbNormal
End Sub

I want to be able to hit cancel and not be flagged by an error message.
 
Hello Michael,

I am assuming that this is an action query and you are
choosing not to complete the operation...

since your code is just this one line, tell Access to ignore
errors

on error resume next
DoCmd.OpenQuery "Daily scanned", vbNormal

also, it is a good idea to give your controls logical names
before you assign code to them.

Change the NAME property of Command21 to something like
cmdRunDailyScanned

Have an awesome day

Warm Regards,
Crystal

MVP Microsoft Access
strive4peace2006 at yahoo.com
 
Thank you Crystal that was very helpful

Crystal said:
Hello Michael,

I am assuming that this is an action query and you are
choosing not to complete the operation...

since your code is just this one line, tell Access to ignore
errors

on error resume next
DoCmd.OpenQuery "Daily scanned", vbNormal

also, it is a good idea to give your controls logical names
before you assign code to them.

Change the NAME property of Command21 to something like
cmdRunDailyScanned

Have an awesome day

Warm Regards,
Crystal

MVP Microsoft Access
strive4peace2006 at yahoo.com
 
you're welcome, Michael ;) happy to help

Have an awesome day

Warm Regards,
Crystal

MVP Microsoft Access
strive4peace2006 at yahoo.com
 
Back
Top