On Error not functioning

B

BobW

I have the following code to delete a temporary query called "temp"

On Error resume next
DoCmd.DeleteObject acQuery , "Temp"
........ more code ....

If query "temp exists all works fine. If query "temp" does not exist instead
of jumping to next line I get the standard error message-
Run-Time error 7874
.....can't find object temp

In fact: ON error GoTo Error_Correct does not work either. Error
correction seems to be disabled. Any ideas on how to fix it.
 
T

Tom Wickerath

Hi Bob,

What setting do you have in the Visual Basic Editor (VBE) for Error Trapping?

==> Tools | Options > General Tab (in VBE, not Access)

If you have "Break on All Errors", your code will......break on all errors!
Change the setting to "Break on Unhandled Errors".

Note: This setting can be changed in the VBE environment using any
VBA-enabled application. Thus, if you are doing something in Excel VBA code,
for instance, where you intentionally set "Break on All Errors", then this is
the setting that your code in Access will be using as well.


Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
__________________________________________
 
L

Lutz Uhlmann

Am 19.01.2010 18:10, schrieb BobW:
I have the following code to delete a temporary query called "temp"

On Error resume next
DoCmd.DeleteObject acQuery , "Temp"
....... more code ....

Try

CurrentDb.QueryDefs.delete "Temp"

this should work with your error handling.
 

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