Suppressing Error Message

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.
 
C

Crystal

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
 
G

Guest

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
 
C

Crystal

you're welcome, Michael ;) happy to help

Have an awesome day

Warm Regards,
Crystal

MVP Microsoft Access
strive4peace2006 at yahoo.com
 

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