>

ReturnsRecords Property

Applies To

QueryDef Object.

Description

Sets or returns a value that indicates whether an SQL pass through query to an external database returns records.

Settings and Return Values

A Boolean expression that indicates whether records are returned. The data type is Boolean. True (-1) (the default) indicates that a pass-through query returns records.

Remarks

Not all SQL pass-through queries to external databases return records. For example, an SQL UPDATE statement updates records without returning records, while an SQL SELECT statement does return records. If the query returns records, set the ReturnsRecords property to True; if the query doesn't return records, set the ReturnsRecords property to False (0).

Note

The Connect property must be set before the ReturnsRecords property is set.

See Also

Connect Property, QueryTimeout Property, SQL Property.

Example

The following example creates an SQL pass-through query that returns records from an external database.


Dim dbsNorthwind As Database, qdfPassThrough As QueryDef
Set dbsNorthwind =  DBEngine.Workspaces(0).OpenDatabase("Northwind.mdb")
Set qdfPassThrough = dbsNorthwind.CreateQueryDef("October " & _
    "Orders","SELECT * From Orders WHERE ShipCity = 'London'")
dbsNorthwind.Connect = "ODBC; DSN=MySQLDBDSN;  " _
    & " UID=Chrissy;PWD=FourOh;"
qdfPassThrough.ReturnsRecords = True
Example (Microsoft Access)

The following example creates an SQL pass-through query that returns records from an external database.


Sub CreatePassThrough()
    Dim dbs As Database, qdfPassThrough As QueryDef

    ' Return Database variable that points to current database.
    Set dbs = CurrentDb
    Set qdfPassThrough = dbs.CreateQueryDef("OctoberOrders", _
"SELECT * From Orders WHERE ShipCity = 'London'") dbs.Connect = "ODBC; DSN=MySQLDBDSN; " _
& " UID=Chrissy;PWD=FourOh;" qdfPassThrough.ReturnsRecords = True End Sub