(HELP) Quick Question dbFailOnError?

K

Kaseano

My Access Program generates a couple tables through a bunch of sequential
quieries.
I get an error message if the tables are there when the program is run a 2nd
time...
SO I put a couple lines into the beginning to remove the tables,

db.Execute "DROP TABLE [GPA Report Table];", dbFailOnError

Now,
I get an error message if the table doesn't exist to be deleted.
I would make an IF statement (if table exists, delete it), but I don't know
how.
I'm also wondering what dbFailOnError means (I've always just written it
without knowing what it did), and whether I can change it to something like
dbNextOnError?


Any Help would be REALLY REALLY appreciated.
Thanks
 
K

Kerry

Hi Kaseano

In the beginning of the procedure have:

On Error GoTo ErrorHandler

Then have the rest of the Code

Then at the end
Exit Sub
ErrorHandler:
Select Case Err.Number
Case 3265 'Object does not exist in this collection (Tried to
delete a table that doesn't exist, so ignore)
Err.Clear
Resume Next
Case Else
MsgBox "An unexpexted error occurred." & vbCrLf & "Error
#" & Err.Number & ": " & Err.Description, vbCritical, "Unexpexted
Error
End Select
End Sub



My Access Program generates a couple tables through a bunch of sequential
quieries.
I get an error message if the tables are there when the program is run a 2nd
time...
SO I put a couple lines into the beginning to remove the tables,

db.Execute "DROP TABLE [GPA Report Table];", dbFailOnError

Now,
I get an error message if the table doesn't exist to be deleted.
I would make an IF statement (if table exists, delete it), but I don't know
how.
I'm also wondering what dbFailOnError means (I've always just written it
without knowing what it did), and whether I can change it to something like
dbNextOnError?

Any Help would be REALLY REALLY appreciated.
Thanks
 
K

Kaseano

I had to get the right error # but it worked, thanks so much Kerry

Kerry said:
Hi Kaseano

In the beginning of the procedure have:

On Error GoTo ErrorHandler

Then have the rest of the Code

Then at the end
Exit Sub
ErrorHandler:
Select Case Err.Number
Case 3265 'Object does not exist in this collection (Tried to
delete a table that doesn't exist, so ignore)
Err.Clear
Resume Next
Case Else
MsgBox "An unexpexted error occurred." & vbCrLf & "Error
#" & Err.Number & ": " & Err.Description, vbCritical, "Unexpexted
Error
End Select
End Sub



My Access Program generates a couple tables through a bunch of sequential
quieries.
I get an error message if the tables are there when the program is run a 2nd
time...
SO I put a couple lines into the beginning to remove the tables,

db.Execute "DROP TABLE [GPA Report Table];", dbFailOnError

Now,
I get an error message if the table doesn't exist to be deleted.
I would make an IF statement (if table exists, delete it), but I don't know
how.
I'm also wondering what dbFailOnError means (I've always just written it
without knowing what it did), and whether I can change it to something like
dbNextOnError?

Any Help would be REALLY REALLY appreciated.
Thanks
 
Top