This article was previously published under Q153756
This article has been archived. It is offered "as is" and will no longer be updated.
IMPORTANT: This article contains information about editing the registry.Before you edit the registry, you should first make a backup copy of theregistry files (System.dat and User.dat). Both are hidden files in theWindows folder.
Advanced: Requires expert coding, interoperability, and multiuser skills.
This article demonstrates how to set the QueryTimeout property for queriesrun against ODBC data sources.
When you're using an ODBC database, such as Microsoft SQL Server, there maybe delays because of network traffic or heavy use of the ODBC server.Rather than waiting indefinitely, you can specify how long to wait beforethe Microsoft Jet database engine produces an error. The defaultQueryTimeout property setting is 60 seconds. This setting may not be longenough to allow some queries to run against ODBC data sources. Thefollowing two methods demonstrate how to change the QueryTimeout property.
NOTE: When using Method 1 to change the QueryTimeout property, the valuewill be set for a specific QueryDef object. When you create a new querythrough the user interface within Microsoft Access 97, the QueryTimeoutproperty will default to 60.
NOTE: When using the steps contained within Method 2 to set theQueryTimeout value within the registry, any new and existing query withinMicrosoft Access will continue to display a value of 60 for theQueryTimeout property. If the value set within the registry is greaterthan the value defined within the individual query, Microsoft Access willuse the value within the registry to determine how long to wait before aQueryTimeout occurs.
Create a subroutine to set the property.
Create and run the following subroutine when you open your database:
Sub SetTimeout() Dim Mydb as Database Set Mydb=CurrentDB MYdb.QueryTimeout=120 End Sub
Once this property is set, it overrides any Windows Registry setting ordefault value.
NOTE: If you are having any problems with the QueryTimeout property, youmay need to upgrade to the most current version of the Microsoft Jetdatabase engine for your version of Microsoft Access. Until then, if youare having problems with CurrentDB.QueryTimeout, you could also try usingDBEngine (0)(0). However, it is recommended that you have the currentversion of the Microsoft Jet database engine.
For information on how to obtain Microsoft Jet 3.51, please see thefollowing article in the Microsoft Knowledge Base:
172733 ACC97: Updated Version of Microsoft Jet 3.5 Available for Download
Example Using DBEngine
Sub mytest() Dim mydb As Database Set mydb = DBEngine(0)(0) mydb.QueryTimeout = 120 MsgBox mydb.QueryTimeout End Sub
Set the property in the Registry.
WARNING: Using Registry Editor incorrectly can cause serious problems thatmay require you to reinstall Windows. Microsoft cannot guarantee thatproblems resulting from the incorrect use of Registry Editor can be solved.Use Registry Editor at your own risk.
For information about how to edit the registry, view the Changing Keys AndValues online Help topic in Registry Editor (Regedit.exe). Note that youshould make a backup copy of the registry files (System.dat and User.dat)before you edit the registry.