Total Visual SourceBook

Total Visual SourceBook CD and Printed Manual

Microsoft Access/ Office 2016, 2013, 2010, and 2007 Version
is Shipping!

New features in Total Visual SourceBook for Access, Office 2007 and VB6

Supports Access/Office 2016, 2013, 2010 and 2007, and Visual Basic 6.0!

Separate version for Access/Office 2003, 2002, and 2000.

Separate version for:
Access 97/95

View all FMS products for Microsoft AccessAll Our Microsoft Access Products

SourceBook Info:

Why SourceBook?


"The code is exactly how I would like to write code and the algorithms used are very efficient and well-documented."

Van T. Dinh, Microsoft MVP




Microsoft Access, Office/VBA, VB6 Modules royalty-free source code libraryMicrosoft Access Modules royalty-free source code libraryMicrosoft Access VBA and VB6 Module Library Free trial of Total Visual SourceBook for Microsoft Access, Office, VB6 and VBA

Class: XMLADO in Category XML Files : XML Files from Total Visual SourceBook

Convert an ADO Recordset to XML using the Microsoft XML Parser with VB6 and VBA.

This class allows you to convert an ADO Recordset to an XML document or load an XML document created with this class, back into an ADO Recordset.

Procedure List

Procedure Name



(Declarations) Declarations Declarations and private variables for the CXMLADO class
SourceFile Property Get the path and name of the XML source file.
Class_Initialize Initialize Initialize the class.
ADOTOXML Method Convert an ADO recordset to an XML document. Note that this does not handle data in binary fields.
CreateDocument Method Create a default Root Document node.
SaveXML Method Save an XML document using the SourceFile property.
XMLTOADO Method Convert an XML document created with the ADOTOXML method to an ADO Recordset.
mxmlDocument_OnDataAvailable Private Event raised by the XML parser when data is available.
mxmlDocument_OnReadyStateChange Private Event raised by the XML parser when the Ready State changes.

Example Code for Using Class: XMLADO

' To use this example:
' 1.  Create a new form.
' 2.  Create the following command buttons: cmdADOToXML, cmdXMLToADO
' 3.  Create the following textboxes: txtSourceFile, txtDocName
' 3.  Paste the entire contents of this module into the new form's module.

' This example assumes that the sample files are located in the folder named by the following constant
Private Const mcstrSamplePath As String = "C:\Total Visual SourceBook 2013\Samples\"
Private Const mcstrExampleDB As String = mcstrSamplePath & "sample.mdb"
Private Const mcstrQueryString As String = "SELECT * FROM Customers"

Private Const mcstrJetProvider351 As String = "Microsoft.Jet.OLEDB.3.51"
Private Const mcstrJetProvider4 As String = "Microsoft.Jet.OLEDB.4.0"
Private Const mcstrJetProvider12 As String = "Microsoft.ACE.OLEDB.12.0"
Private Const mcstrJetProvider14 As String = "Microsoft.ACE.OLEDB.14.0"

Private mclsXML As CXMLADO
Private mcnn As ADODB.Connection
Private mrst As ADODB.Recordset

Private Sub cmdADOTOXML_Click()
  Dim strProvider As String

  ' Use ACE provider to support the 64-bit version of Access.
  #If VBA7 Then
    strProvider = mcstrJetProvider12
    strProvider = mcstrJetProvider4
  #End If

  Set mclsXML = New CXMLADO
  Set mcnn = New ADODB.Connection
  Set mrst = New ADODB.Recordset

  mcnn.Open "Provider=" & strProvider & ";Persist Security Info=False;Data Source=" & mcstrExampleDB
  mrst.Open mcstrQueryString, mcnn, adOpenForwardOnly, adLockReadOnly

  mclsXML.SourceFile = txtSourceFile.Value
  mclsXML.CreateDocument txtDocName.Value
  mclsXML.ADOTOXML mrst

  Set mclsXML = Nothing
  Set mcnn = Nothing
  Set mrst = Nothing

  MsgBox "File Created"

End Sub

Private Sub cmdXMLTOADO_Click()
  Dim oFld As ADODB.Field

  Set mclsXML = New CXMLADO
  Set mcnn = New ADODB.Connection
  Set mrst = New ADODB.Recordset

  mclsXML.SourceFile = txtSourceFile.Value
  Set mrst = mclsXML.XMLTOADO

  Do While Not mrst.EOF
    For Each oFld In mrst.Fields
      Debug.Print oFld.Value
    Next oFld

  Set mclsXML = Nothing
  Set mcnn = Nothing
  Set mrst = Nothing

  MsgBox "File Retrieved"

End Sub

Private Sub Form_Load()
  Me.txtSourceFile.Value = mcstrSamplePath & "ADOXMLTEST.XML"
  Me.txtDocName.Value = "Customers"
  Me.cmdADOToXML.Caption = "ADO to XML"
  Me.cmdXMLToADO.Caption = "XML to ADO"
End Sub

Microsoft Access Module LibraryOverview of Total Visual SourceBook

The source code in Total Visual SourceBook includes modules and classes for Microsoft Access, Visual Basic 6 (VB6), and Visual Basic for Applications (VBA) developers. Easily add this professionally written, tested, and documented royalty-free code into your applications to simplify your application development efforts.

Additional Resources