On Error not working

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

Dirk Goldgar

BobW said:
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.


In the VB Editor's Tools --> Options... dialog, on the General tab, there's
an Error Trapping option. Make sure it isn't set to "Break on All Errors".
I normally have it set to "Break on Unhandled Errors".

If that's not the problem, I'm puzzled.
 
J

JohnR

Here is some code I use to delete queries.

Dim qdf As DAO.QueryDef
For Each qdf In Currentdb.QueryDefs
If qdf.Name = "Temp" Then
db.QueryDefs.Delete qdf.Name
End If
Next qdf
 

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