Using ADO Code to Work with XML

As an alternative, you can use ADO code to work with an XML document. The code that follows provides an example.

Public Sub ExportXMLADO(strTableName as String, strFileName as String)

    Dim rst As ADODB.Recordset

    On Error GoTo ExportXMLADO_Err

    Set rst = New ADODB.Recordset
    rst.Open strTableName, CurrentProject.Connection
    rst.Save CurrentProject.Path & "\" & strFileName, adPersistXML
    rst.Close

    Set rst = Nothing

ExportXMLADO_Exit:
    Exit Sub

ExportXMLADO_Err:
    MsgBox Err.Number & ": " & Err.Description
    Resume ExportXMLADO_Exit
End Sub

The code opens a recordset based on the table name received as the strTableName input parameter. It uses the Save method of the Recordset object to save the resulting recordset as an XML ...

Get Alison Balter's Mastering Access 2002 Enterprise Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.