Break on error even tho error handling is turned on

DataMiner

Registered User.
Local time
Today, 21:42
Joined
Jul 26, 2001
Messages
336
Hi,

I have code that cycles through a bunch of different db files, opening each one and peeking in it briefly for some info, then closing and moving on. If the db file I want to peak in is currently in use, I just skip it. The way I do this is through error handling, something like the following:

For....

set db1=opendatabase(strfolder(i))
[do some peeking here]
db1.close
set db1=nothing

Next....


this is wrapped in a for-next loop. The error handler is set to just progress to the next strfolder if error 3045 (file already in use) is encountered.

The first time it comes to error 3045, it does that just fine. The second time, however, it ignores the error handler and the code just goes into break mode.

I double checked and I do have my options set to "break on unhandled errors". I tried compact/repair to no avail.
Any ideas???
 
Never mind, I figured it out myself!

I had my error hander using "go to NextDB" when it should have been using "resume NextDB". Using GoTo left the error handler active, so the next time it encountered an error while still active, it couldn't handle it.

(Is answering myself worse than just talking to myself....?:)
 
maybe you should check if a .ldb exists first and just skip the error handler event - there are still bugs in Access's error trapping, and while it may work almost always.. if Windows hits a bad memory address, it can screw some things up (noted in previous versions of Access).

Error-trapping should be used as a workaround, as a last resort. Really, in my opinion, it should only be used to help log errors that users encounter so that you (the database admin) can correct the problem and prevent it from happening in the future.
 
Last edited:
I don't think checking for the .ldb file will work, as most of these db's are set to open in exclusive mode.... then I believe that no .ldb file is created.

Anyway, seems to be working OK now that I've changed from "goto" to "resume".
 

Users who are viewing this thread

Back
Top Bottom