Skip to content

Latest commit

 

History

History
47 lines (36 loc) · 2.17 KB

fabricating-hierarchical-recordsets.md

File metadata and controls

47 lines (36 loc) · 2.17 KB
title TOCTitle ms:assetid ms:mtpsurl ms:contentKeyID ms.date mtps_version ms.localizationpriority
Fabricating hierarchical Recordsets
Fabricating hierarchical Recordsets
0a6e41ba-015e-c07e-8876-1e744256b876
48543153
09/18/2015
v=office.15
medium

Fabricating hierarchical Recordsets

Applies to: Access 2013, Office 2013

The following example shows how to fabricate a hierarchical Recordset without an underlying data source by using the data shaping grammar to define columns for parent, child, and grandchild Recordsets.

To fabricate a hierarchical Recordset, you must specify the Microsoft Data Shaping Service for OLE DB (MSDataShape), and you may specify a Data Provider value of NONE in the connection string parameter of the Connection object's Open method. For more information, see Required Providers for Data Shaping.

    Dim cn As New ADODB.Connection
    Dim rsCustomers As New ADODB.Recordset
    
    cn.Open "Provider=MSDataShape;Data Provider=NONE;"
     
    strShape = _
    "SHAPE APPEND NEW adInteger AS CustID," & _
                " NEW adChar(25) AS FirstName," & _
                " NEW adChar(25) AS LastName," & _
                " NEW adChar(12) AS SSN," & _
                " NEW adChar(50) AS Address," & _
             " ((SHAPE APPEND NEW adChar(80) AS VIN_NO," & _
                            " NEW adInteger AS CustID," & _
                            " NEW adChar(20) AS BodyColor, " & _
                         " ((SHAPE APPEND NEW adChar(80) AS VIN_NO," & _
                                        " NEW adChar(20) AS Make, " & _
                                        " NEW adChar(20) AS Model," & _
                                        " NEW adChar(4) AS Year) " & _
                            " AS VINS RELATE VIN_NO TO VIN_NO))" & _
                " AS Vehicles RELATE CustID TO CustID) "
     
    rsCustomers.Open strShape, cn, adOpenStatic, adLockOptimistic, -1

After the Recordset has been fabricated, it can be populated, manipulated, or persisted to a file.