Put XML to Use in Access 2002

<< Click to Display Table of Contents >>

Navigation:  Other Topics > Smart Access 1996-2006 > Jan-2002 >

Put XML to Use in Access 2002


Danny Lesandrini


You’ve heard that XML is easy to import and export from Access 2002, but

you have yet to come up with a good use for it. Danny Lesandrini solves two

problems with Access 2002’s XML support: dynamic file linking and moving

data across applications.


WITH Access 2002, Microsoft has provided support for the hottest of

new technologies—XML. That’s all well and good, but what use

is it? In this article, I’ll show you two different ways that you can

use Access 2002 and XML to solve problems. After a quick review of the

technology, for instance, I’ll show you how to use XML to re-link files.


A quick review

Instead of simply repeating what the Help file says about using XML from

Access 2002, I’ll demonstrate how easy it is to use. The following subroutine

exports the contents of a table named LinkedTables to a file and then reimports

it. The default behavior for the export method (when called from

the Access object) is to overwrite any existing XML file with the same name.

On the other hand, the default behavior for importing is to leave any table

with the same name in place and create a second table, named with an

ordinal suffix. In the following code, I’ve used the flag cOverWrite to cause

the original table to be overwritten during my re-import:


Public Sub ImportExportExample()

Dim sXMLPath As String

Const cOverWrite As Integer = 1

sXMLPath = "D:\KBSearch\LinkedTables.xml"

' ExportXML ObjectType, DataSource, DataTarget

ExportXML acExportTable, "LinkedTables", sXMLPath

' ImportXML DataSource, DataTransform, OtherFlags

ImportXML sXMLPath, acStructureAndData, cOverWrite

End Sub


Read More Here:

Put XML to Use in Access 2002