Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error checking does not work 1

Status
Not open for further replies.

Techno1X

Programmer
Mar 21, 2008
12
CA
Hi,

I can't get the following error checking methods to function properly. In these, the compiler jumps past the statement as if it was never there..

1. Trying to delete a table:
On Error Resume Next
dbOne.TableDefs.Delete tblFun

2.Append the new table to database
On Error Resume Next
dbOne.TableDefs.Append tblFun

If it could be missing libraries, does anyone know which - otherwise, please help. :) thanks
 




When using On Error Resume Next, you ought to be checking the Err object to trap the kind of errors you can possibly getting, and then you need to program around recoveries for each error.
Code:
On Error Resume next

'now goes the statement that you expect to error

if err.number <> 0 then
   'here's where your error trapping goes
end if


Skip,
[sub]
[glasses]Have you heard that the roundest knight at King Arthur's round table was...
Sir Cumference![tongue][/sub]
 
I've tried that; however, I just want the program to ignore the statement if it reaches an error. Hence "resume next".

One thing I did was use the trapping object with an empty inside block: i.e.
If Err.Number <> 0 Then
End If

But it still gives an error at:
"dbOne.TableDefs.Delete tblFun"
 




Code:
dbOne.TableDefs.Delete tblFun
how is tblFun declared?

This argument must be a STRING. Maybe...
Code:
dbOne.TableDefs.Delete tblFun[b].Name[/b]
if this is a table object.

Skip,
[sub]
[glasses]Have you heard that the roundest knight at King Arthur's round table was...
Sir Cumference![tongue][/sub]
 
No, it's a String, I checked.

Is it possible that other portions of code could affect a single "On Error" statement? Note that *none* of the "On Error" statements work in my case.

On the top I declared:
Option Compare Database
Option Base 1
 




Put a break in your code.

Use the Watch Window to observe the value in your variables and the Err object.

Skip,
[sub]
[glasses]Have you heard that the roundest knight at King Arthur's round table was...
Sir Cumference![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top