Solved

handle ODBC timeout programmatically to continue execution

Posted on 2007-04-03
6
434 Views
Last Modified: 2009-07-29
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"
etc.

0
Comment
Question by:ToddRod_Taylor
  • 2
  • 2
  • 2
6 Comments
 
LVL 2

Accepted Solution

by:
kathik earned 250 total points
Comment Utility
If you really don't want to trap for errors, you can always use this statement before the first docmd line:

ON ERROR RESUME NEXT
0
 

Author Comment

by:ToddRod_Taylor
Comment Utility
After a procedure with ON ERROR RESUME NEXT set finishes, does that go back to a default ?
0
 
LVL 2

Expert Comment

by:kathik
Comment Utility
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.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 1

Assisted Solution

by:glennwaldron
glennwaldron earned 250 total points
Comment Utility
Wouldn't you be better off to set it up like

Sub Doqueries
On error goto error_trap

'list of queries
.
...

Exit_Here:
Exit Sub
Error_Trap:
'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


Glenn
0
 

Author Comment

by:ToddRod_Taylor
Comment Utility
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!
0
 
LVL 1

Expert Comment

by:glennwaldron
Comment Utility
Thanls for the points and glad to be of help.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now