Solved

handle ODBC timeout programmatically to continue execution

Posted on 2007-04-03
6
440 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
ID: 18847180
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
ID: 18847197
After a procedure with ON ERROR RESUME NEXT set finishes, does that go back to a default ?
0
 
LVL 2

Expert Comment

by:kathik
ID: 18847260
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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 1

Assisted Solution

by:glennwaldron
glennwaldron earned 250 total points
ID: 18848692
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
ID: 18860496
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
ID: 18868263
Thanls for the points and glad to be of help.
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

860 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