DAO Object
 
Recordset object represents the records in a base table or the records that result from running a query.
 

Remarks

You use Recordset objects to manipulate data in a database at the record level. When you use DAO objects, you manipulate data almost entirely using Recordset objects. All Recordset objects are constructed using records (rows) and fields (columns). There are five types of Recordset objects:
 
 Note
ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.
 
You can choose the type of Recordset object you want to create using the type argument of the OpenRecordset method.
 
In a Microsoft Access workspace, if you don't specify a type, DAO attempts to create the type of Recordset with the most functionality available, starting with table. If this type isn't available, DAO attempts a dynaset, then a snapshot, and finally a forward-only type Recordset object.
 
In an ODBCDirect workspace, if you don't specify a type, DAO attempts to create the type of Recordset with the fastest query response, starting with forward-only. If this type isn't available, DAO attempts a snapshot, then a dynaset, and finally a dynamic- type Recordset object.
 
When creating a Recordset object using a non-linked TableDef object in a Microsoft Access workspace, table-type Recordset objects are created. Only dynaset-type or snapshot-type Recordset objects can be created with linked tables or tables in Microsoft Access database engine-connected ODBC databases.
 
A new Recordset object is automatically added to the Recordsets collection when you open the object, and is automatically removed when you close it.
 
 Note
If you use variables to represent a Recordset object and the Database object that contains the Recordset, make sure the variables have the same scope, or lifetime. For example, if you declare a public variable that represents a Recordset object, make sure the variable that represents the Database containing the Recordset is also public, or is declared in a Sub or Function procedure using the Static keyword.
 
You can create as many Recordset object variables as needed. Different Recordset objects can access the same tables, queries, and fields without conflicting.
 
Dynaset–, snapshot–, and forward–only–type Recordset objects are stored in local memory. If there isn't enough space in local memory to store the data, the Microsoft Access database engine saves the additional data to TEMP disk space. If this space is exhausted, a trappable error occurs.
 
The default collection of a Recordset object is the Fields collection, and the default property of a Field object is the Value property. Use these defaults to simplify your code.
 
When you create a Recordset object, the current record is positioned to the first record if there are any records. If there are no records, the RecordCount property setting is 0, and the BOF and EOF property settings are True.
 
You can use the MoveNextMovePreviousMoveFirst, and MoveLast methods to reposition the current record. Forward–only–type Recordset objects support only the MoveNext method. When using the Move methods to visit each record (or "walk" through the Recordset), you can use the BOF and EOF properties to check for the beginning or end of the Recordset object.
 
With dynaset- and snapshot-type Recordset objects in a Microsoft Access workspace, you can also use the Find methods, such as FindFirst, to locate a specific record based on criteria. If the record isn't found, the NoMatch property is set to True. For table-type Recordset objects, you can scan records using the Seek method.
 
The Type property indicates the type of Recordset object created, and the Updatable property indicates whether you can change the object's records.
 
Information about the structure of a base table, such as the names and data types of each Field object and any Index objects, is stored in a TableDef object.
 
To refer to a Recordset object in a collection by its ordinal number or by its Name property setting, use any of the following syntax forms:
 
 Note
You can open a Recordset object from the same data source or database more than once, creating duplicate names in the Recordsets collection. You should assign Recordset objects to object variables and refer to them by variable name.
 

Methods

Name
Description
Creates a new record for an updatable Recordset object.
NOTE: ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.
Cancels execution of a pending asynchronous method call (ODBCDirect workspaces only).
Cancels any pending updates for a Recordset object.
Creates a duplicate Recordset object that refers to the original Recordset object.
Closes an open Recordset.
Returns a QueryDef object that is a copy of the QueryDef used to create the Recordset object represented by the recordset placeholder (Microsoft Access workspaces only). .
Not supported for this object.
Copies the current record from an updatable Recordset object to the copy buffer for subsequent editing.
Fills all or a part of a local cache for a Recordset object that contains data from a Microsoft Access database engine-connected ODBC data source (Microsoft Access database engine-connected ODBC databases only).
Locates the first record in a dynaset- or snapshot-type Recordset object that satisfies the specified criteria and makes that record the current record (Microsoft Access workspaces only).
Locates the last record in a dynaset- or snapshot-type Recordset object that satisfies the specified criteria and makes that record the current record (Microsoft Access workspaces only).
Locates the next record in a dynaset- or snapshot-type Recordset object that satisfies the specified criteria and makes that record the current record (Microsoft Access workspaces only). .
Locates the previous record in a dynaset- or snapshot-type Recordset object that satisfies the specified criteria and makes that record the current record (Microsoft Access workspaces only). .
Retrieves multiple rows from a Recordset object.
Moves the position of the current record in a Recordset object.
Moves to the first record in a specified Recordset object and make that record the current record.
Moves to the last record in a specified Recordset object and make that record the current record.
Moves to the next record in a specified Recordset object and make that record the current record.
Moves to the previous record in a specified Recordset object and make that record the current record.
NOTE: ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.
Gets the next set of records, if any, returned by a multi-part select query in an OpenRecordset call, and returns a Boolean value indicating whether one or more additional records are pending (ODBCDirect workspaces only).
Creates a new Recordset object and appends it to the Recordsets collection.
Updates the data in a Recordset object by re-executing the query on which the object is based.
Locates the record in an indexed table-type Recordset object that satisfies the specified criteria for the current index and makes that record the current record (Microsoft Access workspaces only).
NOTE: ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.
Saves the contents of the copy buffer to an updatable Recordset object.
 

Properties

Name
Description
Sets or returns the relative record number of a Recordset object's current record.
NOTE: ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.
Returns the number of records that did not complete the last batch update (ODBCDirect workspaces only).
NOTE: ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.
Returns an array of bookmarks indicating the rows that generated collisions in the last batch update operation (ODBCDirect workspaces only).
NOTE: ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.
Sets or returns the number of statements sent back to the server in each batch (ODBCDirect workspaces only).
Returns a value that indicates whether the current record position is before the first record in a Recordset object. Read-only Boolean.
Sets or returns a bookmark that uniquely identifies the current record in a Recordset object.
Returns a value that indicates whether a Recordset object supports bookmarks, which you can set by using the Bookmark property.
Sets or returns the number of records retrieved from an ODBC data source that will be cached locally. Read/write Long.
Sets or returns a value that specifies the bookmark of the first record in a dynaset-type Recordset object containing data to be locally cached from an ODBC data source (Microsoft Access workspaces only).
Returns the Connection object that corresponds to the database.
Returns the date and time a base table was created (Microsoft Access workspaces only). Read-only Variant.
Returns a value that indicates the state of editing for the current record.
Returns a value that indicates whether the current record position is after the last record in a Recordset object. Read-only Boolean.
Returns a Fields collection that represents all stored Field objects for the specified object. Read-only.
Sets or returns a value that determines the records included in a subsequently opened Recordset object (Microsoft Access workspaces only). Read/write String.
Sets or returns a value that indicates the name of the current Index object in a table-type Recordset object (Microsoft Access workspaces only).
Returns a ookmark indicating the most recently added or changed record.
Returns the date and time of the most recent change made to a base table. Read-only Variant.
Sets or returns a value indicating the type of locking that is in effect while editing.
Returns the name of the specified object. Read-only String.
Indicates whether a particular record was found by using the Seek method or one of the Find methods (Microsoft Access workspaces only).
Sets or returns a value indicating the approximate location of the current record in the Recordset object based on a percentage of the records in the Recordset.
Returns the Properties collection of the specified object. Read-only.
Returns the number of records accessed in a Recordset object, or the total number of records in a table-type Recordset object. or TableDef object. Read-only Long.
NOTE: ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.
Returns a value indicating the update status of the current record if it is part of a batch update (ODBCDirect workspaces only). Read-only RecordStatusEnum.
Returns a value that indicates whether a Recordset object supports the Requery method, which re-executes the query on which the Recordset object is based.
Sets or returns the sort order for records in a Recordset object (Microsoft Access workspaces only).
NOTE: ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.
Indicates whether or not an asynchronous operation (that is, a method called with the dbRunAsync option) has finished executing (ODBCDirect workspaces only).
Returns a value that indicates whether an object supports transactions. Read-only Boolean.
The description for this member will appear in the final release of Office 14.
Returns a value that indicates whether you can change a DAO object. Read-only Boolean.
NOTE: ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.
Sets or returns a value that indicates how the WHERE clause is constructed for each record during a batch update, and whether the batch update should use an UPDATE statement or a DELETE followed by an INSERT (ODBCDirect workspaces only). Read/write UpdateCriteriaEnum.
Sets or returns a value that validates the data in a field as it's changed or added to a table (Microsoft Access workspaces only).Read/write String.
Sets or returns a value that specifies the text of the message that your application displays if the value of a Field object doesn't satisfy the validation rule specified by the ValidationRule property setting (Microsoft Access workspaces only). Read-only String.
 

Example

This example demonstrates Recordset objects and the Recordsets collection by opening four different types of Recordsets, enumerating the Recordsets collection of the current Database, and enumerating the Properties collection of each Recordset.
 
Sub RecordsetX()
    
       Dim dbsNorthwind As Database
       Dim rstTable As Recordset
       Dim rstDynaset As Recordset
       Dim rstSnapshot As Recordset
       Dim rstForwardOnly As Recordset
       Dim rstLoop As Recordset
       Dim prpLoop As Property
    
       Set dbsNorthwind = OpenDatabase("Northwind.mdb")
    
       With dbsNorthwind
    
          ' Open one of each type of Recordset object.
          Set rstTable = .OpenRecordset("Categories", _
             dbOpenTable)
          Set rstDynaset = .OpenRecordset("Employees", _
             dbOpenDynaset)
          Set rstSnapshot = .OpenRecordset("Shippers", _
             dbOpenSnapshot)
          Set rstForwardOnly = .OpenRecordset _ 
             ("Employees", dbOpenForwardOnly)
    
          Debug.Print "Recordsets in Recordsets " & _
             "collection of dbsNorthwind"
    
          ' Enumerate Recordsets collection.
          For Each rstLoop In .Recordsets
    
             With rstLoop
                Debug.Print "  " & .Name
    
                ' Enumerate Properties collection of each
                ' Recordset object. Trap for any 
                ' properties whose values are invalid in 
                ' this context.
                For Each prpLoop In .Properties
                   On Error Resume Next
                   If prpLoop <> "" Then Debug.Print _
                      "    " & prpLoop.Name & _
                      " = " & prpLoop
                   On Error GoTo 0
                Next prpLoop
    
             End With
    
          Next rstLoop
    
          rstTable.Close
          rstDynaset.Close
          rstSnapshot.Close
          rstForwardOnly.Close
    
          .Close
       End With
    
End Sub
 
 
This example uses the OpenRecordset method to open five different Recordset objects and display their contents. The OpenRecordsetOutput procedure is required for this procedure to run.
 
Sub OpenRecordsetX()
    
       Dim wrkAcc As Workspace
       Dim wrkODBC As Workspace
       Dim dbsNorthwind As Database
       Dim conPubs As Connection
       Dim rstTemp As Recordset
       Dim rstTemp2 As Recordset
    
       ' Open Microsoft Access and ODBCDirect workspaces, Microsoft 
       ' Access database, and ODBCDirect connection.
       Set wrkAcc = CreateWorkspace("", "admin", "", dbUseJet)
       Set wrkODBC = CreateWorkspace("", "admin", "", dbUseODBC)
       Set dbsNorthwind = wrkAcc.OpenDatabase("Northwind.mdb")
       
       ' Note: The DSN referenced below must be set to 
       '       use Microsoft Windows NT Authentication Mode to 
       '       authorize user access to the Microsoft SQL Server.
       Set conPubs = wrkODBC.OpenConnection("", , , _
          "ODBC;DATABASE=pubs;DSN=Publishers")
    
       ' Open five different Recordset objects and display the 
       ' contents of each.
    
       Debug.Print "Opening forward-only-type recordset " & _
          "where the source is a QueryDef object..."
       Set rstTemp = dbsNorthwind.OpenRecordset( _
          "Ten Most Expensive Products", dbOpenForwardOnly)
       OpenRecordsetOutput rstTemp
    
       Debug.Print "Opening read-only dynaset-type " & _
          "recordset where the source is an SQL statement..."
       Set rstTemp = dbsNorthwind.OpenRecordset( _
          "SELECT * FROM Employees", dbOpenDynaset, dbReadOnly)
       OpenRecordsetOutput rstTemp
    
       ' Use the Filter property to retrieve only certain 
       ' records with the next OpenRecordset call.
       Debug.Print "Opening recordset from existing " & _
          "Recordset object to filter records..."
       rstTemp.Filter = "LastName >= 'M'"
       Set rstTemp2 = rstTemp.OpenRecordset()
       OpenRecordsetOutput rstTemp2
    
       Debug.Print "Opening dynamic-type recordset from " & _
          "an ODBC connection..."
       Set rstTemp = conPubs.OpenRecordset( _
          "SELECT * FROM stores", dbOpenDynamic)
       OpenRecordsetOutput rstTemp
    
       ' Use the StillExecuting property to determine when the 
       ' Recordset is ready for manipulation.
       Debug.Print "Opening snapshot-type recordset based " & _
          "on asynchronous query to ODBC connection..."
       Set rstTemp = conPubs.OpenRecordset("publishers", _
          dbOpenSnapshot, dbRunAsync)
       Do While rstTemp.StillExecuting
          Debug.Print "  [still executing...]"
       Loop
       OpenRecordsetOutput rstTemp
    
       rstTemp.Close
       dbsNorthwind.Close
       conPubs.Close
       wrkAcc.Close
       wrkODBC.Close
    
    End Sub
    
    Sub OpenRecordsetOutput(rstOutput As Recordset)
    
       ' Enumerate the specified Recordset object.
       With rstOutput
          Do While Not .EOF
             Debug.Print , .Fields(0), .Fields(1)
             .MoveNext
          Loop
       End With
    
End Sub
 
 
This example opens a dynamic-type Recordset object and enumerates its records.
 
Sub dbOpenDynamicX()
    
       Dim wrkMain As Workspace
       Dim conMain As Connection
       Dim qdfTemp As QueryDef
       Dim rstTemp As Recordset
       Dim strSQL As String
       Dim intLoop As Integer
    
       ' Create ODBC workspace and open connection to
       ' SQL Server database.
       Set wrkMain = CreateWorkspace("ODBCWorkspace", _
          "admin", "", dbUseODBC)
          
       ' Note: The DSN referenced below must be configured to 
       '       use Microsoft Windows NT Authentication Mode to 
       '       authorize user access to the Microsoft SQL Server.    
       Set conMain = wrkMain.OpenConnection("Publishers", _
          dbDriverNoPrompt, False, _
          "ODBC;DATABASE=pubs;DSN=Publishers")
          
       ' Open dynamic-type recordset.
       Set rstTemp = _
          conMain.OpenRecordset("authors", _
          dbOpenDynamic)
    
       With rstTemp
          Debug.Print "Dynamic-type recordset: " & .Name
    
          ' Enumerate records.
          Do While Not .EOF
             Debug.Print "    " & !au_lname & ", " & _
                !au_fname
             .MoveNext
          Loop
    
          .Close
       End With
    
       conMain.Close
       wrkMain.Close
    
End Sub
 
 
This example opens a dynaset-type Recordset and shows the extent to which its fields are updatable.
 
Sub dbOpenDynasetX()
    
       Dim dbsNorthwind As Database
       Dim rstInvoices As Recordset
       Dim fldLoop As Field
    
       Set dbsNorthwind = OpenDatabase("Northwind.mdb")
       Set rstInvoices = _
          dbsNorthwind.OpenRecordset("Invoices", dbOpenDynaset)
    
       With rstInvoices
          Debug.Print "Dynaset-type recordset: " & .Name
    
          If .Updatable Then
             Debug.Print "  Updatable fields:"
    
             ' Enumerate Fields collection of dynaset-type
             ' Recordset object, print only updatable
             ' fields.
             For Each fldLoop In .Fields
                If fldLoop.DataUpdatable Then
                   Debug.Print "    " & fldLoop.Name
                End If
             Next fldLoop
    
          End If
    
          .Close
       End With
    
       dbsNorthwind.Close
    
End Sub
 
 
This example opens a forward-only-type Recordset, demonstrates its read-only characteristics, and steps through the Recordset with the MoveNext method.
 
Sub dbOpenForwardOnlyX()
 
   Dim dbsNorthwind As Database
   Dim rstEmployees As Recordset
   Dim fldLoop As Field
 
   Set dbsNorthwind = OpenDatabase("Northwind.mdb")
   ' Open a forward-only-type Recordset object. Only the 
   ' MoveNext and Move methods may be used to navigate 
   ' through the recordset.
   Set rstEmployees = _
      dbsNorthwind.OpenRecordset("Employees", _
      dbOpenForwardOnly)
 
   With rstEmployees
      Debug.Print "Forward-only-type recordset: " & _
         .Name & ", Updatable = " & .Updatable
 
      Debug.Print "  Field - DataUpdatable"
      ' Enumerate Fields collection, printing the Name and 
      ' DataUpdatable properties of each Field object.
      For Each fldLoop In .Fields
         Debug.Print "    " & _
            fldLoop.Name & " - " & fldLoop.DataUpdatable
      Next fldLoop
 
      Debug.Print "  Data"
      ' Enumerate the recordset.
      Do While Not .EOF
         Debug.Print "    " & !FirstName & " " & _
            !LastName
         .MoveNext
      Loop
 
      .Close
   End With
 
   dbsNorthwind.Close
 
End Sub
 
 
This example opens a snapshot-type Recordset and demonstrates its read-only characteristics.
 
Sub dbOpenSnapshotX()
    
       Dim dbsNorthwind As Database
       Dim rstEmployees As Recordset
       Dim prpLoop As Property
    
       Set dbsNorthwind = OpenDatabase("Northwind.mdb")
       Set rstEmployees = _
          dbsNorthwind.OpenRecordset("Employees", _
          dbOpenSnapshot)
    
       With rstEmployees
          Debug.Print "Snapshot-type recordset: " & _
             .Name
    
          ' Enumerate the Properties collection of the
          ' snapshot-type Recordset object, trapping for
          ' any properties whose values are invalid in 
          ' this context.
          For Each prpLoop In .Properties
             On Error Resume Next
             Debug.Print "  " & _
                prpLoop.Name & " = " & prpLoop
             On Error Goto 0
          Next prpLoop
    
          .Close
       End With
    
       dbsNorthwind.Close
    
End Sub
 
 
This example opens a table-type Recordset, sets its Index property, and enumerates its records.
 
Sub dbOpenTableX()
    
       Dim dbsNorthwind As Database
       Dim rstEmployees As Recordset
    
       Set dbsNorthwind = OpenDatabase("Northwind.mdb")
       ' dbOpenTable is default.
       Set rstEmployees = _
          dbsNorthwind.OpenRecordset("Employees")
    
       With rstEmployees
          Debug.Print "Table-type recordset: " & .Name
    
          ' Use predefined index.
          .Index = "LastName"
          Debug.Print "  Index = " & .Index
    
          ' Enumerate records.
          Do While Not .EOF
             Debug.Print "    " & !LastName & ", " & _
                !FirstName
             .MoveNext
          Loop
    
          .Close
       End With
    
       dbsNorthwind.Close
    
End Sub
 
 
The following example shows how to use the Seek method to find a record in a linked table.
 
Sub TestSeek()
        ' Get the path to the external database that contains
        ' the tblCustomers table we're going to search.
        Dim strMyExternalDatabase
        Dim dbs    As DAO.Database
        Dim dbsExt As DAO.Database
        Dim rst    As DAO.Recordset
        Dim tdf    As DAO.TableDef
       
        Set dbs = CurrentDb()
        Set tdf = dbs.TableDefs("tblCustomers")
        strMyExternalDatabase = Mid(tdf.Connect, 11)
       
        'Open the database that contains the table that is linked
        Set dbsExt = OpenDatabase(strMyExternalDatabase)
       
        'Open a table-type recordset against the external table
        Set rst = dbsExt.OpenRecordset("tblCustomers", dbOpenTable)
       
        'Specify which index to search on
        rst.Index = "PrimaryKey"
       
        'Specify the criteria
        rst.Seek "=", 123
       
        'Check the result
        If rst.NoMatch Then
            MsgBox "Record not found."
        Else
            MsgBox "Customer name: " & rst!CustName
        End If
       
        rst.Close
        dbs.Close
        dbsExt.Close
        Set rst = Nothing
        Set tdf = Nothing
        Set dbs = Nothing
       
       
    End Sub
 
 
The following example shows how to open a Recordset that is based on a parameter query.
 
   Dim dbs As DAO.Database
    Dim qdf As DAO.QueryDef
    Dim rst As DAO.Recordset
   
    Set dbs = CurrentDb
   
    'Get the parameter query
    Set qfd = dbs.QueryDefs("qryMyParameterQuery")
   
    'Supply the parameter value
    qdf.Parameters("EnterStartDate") = Date
    qdf.Parameters("EnterEndDate") = Date + 7
   
    'Open a Recordset based on the parameter query
    Set rst = qdf.OpenRecordset()
 
 
The following example shows how to open a Recordset based on a table or a query.
 
    Dim dbs As DAO.Database
    Dim rsTable As DAO.Recordset
    Dim rsQuery As DAO.Recordset
   
    Set dbs = CurrentDb
   
    'Open a table-type Recordset
    Set rsTable = dbs.OpenRecordset("Table1", dbOpenTable)
   
    'Open a dynaset-type Recordset using a saved query
    Set rsQuery = dbs.OpenRecordset("qryMyQuery", dbOpenDynaset)
 
 
The following example shows how to open a Recordset based on a Structured Query Language (SQL) statement.
 
    Dim dbs As DAO.Database
    Dim rsSQL As DAO.Recordset
    Dim strSQL As String
   
    Set dbs = CurrentDb
   
    'Open a snapshot-type Recordset based on an SQL statement
    strSQL = "SELECT * FROM Table1 WHERE Field2 = 33"
    Set rsSQL = dbs.OpenRecordset(strSQL, dbOpenSnapshot)
 
 
The following example shows how to use the FindFirst and FindNext methods to find a record in a Recordset.
 
Sub FindOrgName()
   
        Dim dbs As DAO.Database
        Dim rst As DAO.Recordset
       
        'Get the database and Recordset
        Set dbs = CurrentDb
        Set rst = dbs.OpenRecordset("tblCustomers")
   
        'Search for the first matching record  
        rst.FindFirst "[OrgName] LIKE '*parts*'"
       
        'Check the result
        If rst.NoMatch Then
            MsgBox "Record not found."
            GotTo Cleanup
        Else
            Do While Not rst.NoMatch
                MsgBox "Customer name: " & rst!CustName
                rst.FindNext "[OrgName] LIKE '*parts*'"
            Loop
   
            'Search for the next matching record
            rst.FindNext "[OrgName] LIKE '*parts*'"
        End If
      
        Cleanup:
            rst.Close
            Set rst = Nothing
            Set dbs = Nothing
   
End Sub
 
The following example shows how to copy the results of a query to a worksheet in a new Microsoft Excel workbook.
 
Public Sub CopyDataFromQuery( _
        xlApp As Excel.Application, _
        strQueryName As String)
   
        ' If the xlApp object exists
        If Not xlApp Is Nothing Then
       
            ' If the Workbook exists
            If xlApp.Workbooks.Count = 1 Then
           
                ' Create Recrodset Object from the Query
                Dim rsQuery As DAO.Recordset
                Set rsQuery = Application.CurrentDb.OpenRecordset(strQueryName)
               
                ' Get the Cells object
                Dim Cells As Object
                Set Cells = xlApp.Workbooks(1).ActiveSheet.Cells
               
                ' Copy the Data from the Query into the Sheet
                Cells.CopyFromRecordset rsQuery
               
            End If
        End If
   
End Sub