• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 471
  • Last Modified:

handle ODBC timeout programmatically to continue execution

I have a large program with queries to 80+ different SQL servers over the net.

My problem: how can I programmactically handle timeouts when they occur due to 1 or more of those servers being down; and thus not stop execution with an error box, but continue executing the remainder of the lines in my code; in effect "skipping" the one that timed out?

I simply have 80+ of these:
DoCmd.OpenQuery "1-POS"
DoCmd.OpenQuery "2-POS"
DoCmd.OpenQuery "3-POS"

  • 2
  • 2
  • 2
2 Solutions
If you really don't want to trap for errors, you can always use this statement before the first docmd line:

ToddRod_TaylorAuthor Commented:
After a procedure with ON ERROR RESUME NEXT set finishes, does that go back to a default ?
The ON ERROR RESUME NEXT will be local to that procedure.  So, if a calling procedure has different error handling, it will take over once this one is finished.  I think the default error handling in MS Access is just to break at the error.
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Wouldn't you be better off to set it up like

Sub Doqueries
On error goto error_trap

'list of queries

Exit Sub
'now you can handle the errors any way you want
Select Case Err.Number
  Case 1024 (or whatever the error you want to trap)
     do something, possibly write an error log to tell you what query failed
     resume next  'this takes you to the next query
   Case else
       do something
       goto Exit_Here

This allows you to keep track of all errors not just one specific error

Hope this helps

ToddRod_TaylorAuthor Commented:
foolish me.....
the ON ERROR RESUME NEXT is perfect ; down-n-dirty

trapping for which one failed I liked as well.

I used the ON ERROR RESUME for a few days, then coded the trap to tell me which servers where down.  Both served my needs, thanks!
Thanls for the points and glad to be of help.

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now