LoginTimeout Property Example (MDB)

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

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

    ' Set timeout to 120 seconds.
    DBEngine.LoginTimeout = 120
    ' Return reference to current database.
    Set dbs = CurrentDb
    ' Create new QueryDef object.
    Set qdf = dbs.CreateQueryDef("All Employees", _
        "SELECT * FROM Employees;")
    qdf.Connect = "ODBC;DSN=Human Resources; " _
        & "Database=HRSRVR; UID=Smith; PWD=Sesame"
    ' Log on to server and run query.
    Set rst = qdf.OpenRecordset()
    ' Perform operations with recordset.
    .
    .
    .
    rst.Close
    Set dbs = Nothing
End Sub