Wednesday, October 10, 2007

Increase ODBCTimeout property for all queries in an Access Database



If you ever have problems with Access queries timing out you can right-click in the query builder and set the ODBCTimeout property in the property window or you can run this code which will increase the ODBCTimeout property of all the queries in the database. You can just paste this code in a module and then run it and all the queries will have their timeout reset. I have some code that runs about 40 Access queries in a row and some of them were timing out and I found it easier to just change them all at once instead each one manually. Of course if you have too many queries timing out or if they still timeout after setting them to the maximum (6000) then you may need to convert you queries to SQL Server or whatever server database you are using. SQL Server is almost always faster than Access at running queries.



Dim qdfs As QueryDefs, qdf As QueryDef
Set qdfs = CurrentDb.QueryDefs
For Each qdf In qdfs
qdf.ODBCTimeout = 6000
Next

No comments: