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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Want to close DB on any runtime error

Status
Not open for further replies.

VicM

Programmer
Sep 24, 2001
444
US
Hi,

We have several DBs that contain global variables which are set either upon opening or during some other function.
However, when the DB experiences a runtime error, the code window pops open with a window asking to End or Debug.

In either case, the outcome is that all the global variables are reset to empty. So if the user selected the End button and tried to continue on in the DB, this would often create incomplete records, since some of the info is supplied by the global variables. And as a result, those records are not accessible because of the missing data.

We've tried instructing the users to select the End button, but then exit from the DB and then reopen it so that the globals are re-established. Either because of personnel turnover or ignorance, the user will try to continue using the DB after selecting the End button.

Is there a way to 'globally' capture any runtime error and cause the DB to close, without having to code every subroutine in the code window for that occurrence?

Thanks,

Vic
 
First of all, if i'm not mistaken,
if you have your own error handling, in every sub,
the global variables will not deinitialize!

I have a generic error handler, which when called,
resets the database , to it's intial state.
______________________________________
Private Sub cmdTotal_Click()
On Error GoTo xxx

....

xx:
Exit Sub
xxx:
Call ErrorLog(Me.Name,err,Error$,err.Source)
End Sub

__________________________________________________

Sub errorLog(strForm As Form, intErrNº as Intege.....)


MsgBox intErrNº & vbcrLf & strErrDesc


Docmd.EchoOn True
Docmd.Hourglass False
Docmd.SetWarnings True
SET YOUR VARIABLES HERE?

End Sub


but again, every routine will need to call this.
I don't see a way, out of this.
even if you wrote "On error Resume Next" at the top
of each procedure, it will have to be in EACH procedure?

there are a few 3rd party utilities, which will insert
an error handler into everry routine, in one fell swoop.
I use "zada solutions.uk", it allows me to template my error handlers,to accomodate my generic sub call.
there's also "MZTools"

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top