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!

How does Access decide which Error Routine?

Status
Not open for further replies.

Petemush

Technical User
Jun 21, 2002
255
GB
Hey,

When an error occurs in the runtime of your code, hopefully you've written some error handling to deal with it.

My question is, how does access decide which error routine to use?

Say you open a form and some form open code (with error handling) runs and calls another procedure(also with error handling). If an error occurs, which error handling routine does access use?

Does it use both? So it leaps into the called procedure's error handling, exits, and then leaps back to the form open code and then into the form open code's error handling?

Or does it use the form open's error handling only?

I ask, simply to work out how rock solid to write my routines, ie I don't turn echo off in one procedure but I call a sub procedure that does. Do I have to make sure I turn echo back on in the parent procedure's error handling?

Cheers,

Pete
 
I thought that the error handling (I also assume we are talking about the On Error... bits) was specific to the function the error happened within. For example if your form opens, and calls another function which tries to open a recordset. If the recordset can't open, dues to syntax errors, or whatever, then that function has failed - you've got an error. However this isn't anything to do with an the form openning - the form can still open.

Personally, I would have the Function that opens the recordset return a false if it has any problems, so that the Form_Open can act accordingly - it all comes down to dependancies - if you are running that code as a background process, then does that stop the main form from opening properly. However, if the main form is opening, and using the connect recordset function to populate the controls on the form you've opened, then the form is pretty useless now the recordset has failed!

I'm not really sure I've answered your question here, but its my 2p
 
If the sub or function where the error occurs has an error trapping section, that's where the error is handled. The error is cleared after having been dealt with.
If such sub or function does not have an error trapping section, the error is passed to the code that has called the 'offending' sub or function.

If you have good error trapping code in each sub or function, the errors will be handled locally.
However, keep in mind that an error could occur in the error handling routine lol

Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top