ODBCTimeout Property Example (MDB)

The following example sets the ODBCTimeout property to 120 seconds, creates a query, and runs it on a database on an ODBC server:

Sub SetTimeout()
    Dim dbs As Database
    Dim qdf As QueryDef, rst As Recordset

    ' Return reference to current database.
    Set dbs = CurrentDb
    ' Create new QueryDef object.
    Set qdf = dbs.CreateQueryDef("All Cust", _
        "SELECT * FROM Customers;")
    qdf.Connect = "ODBC;DSN=HumanResources;SERVER=HRSRVR: " _
        & "UID=Smith; PWD=Sesame"
    ' Log on to server and run query.
    qdf.ODBCTimeout = 120
    Set rst = qdf.OpenRecordset()
    ' Perform operations with recordset.
    .
    .
    .
    rst.Close
    Set dbs = Nothing
End Sub