Exporting Access tables to XML

hinke

New member
Local time
Today, 15:31
Joined
Jan 21, 2010
Messages
3
Hi,

I have been hitting my head against the wall the last few days because I can't get the export of access tables to XML to work.

I have 3 tables total.

Table1 is the main table and can have many records of Table2. Table2 can have many records of Table3.

When I export via Application.ExportXML the last table (Table3) ends outside the tag of Table1. Really it should have ended up inside the tag for Table2.

Here's the strange thing, if I use the export feature from the File menu, it works perfect! So I can't say that the relationship model is messed up or not.

Code:
Dim adOtherTables As AdditionalData
Set adOtherTables = Application.CreateAdditionalData
adOtherTables.Add "User_Org"
adOtherTables.Add "Location_Privilege"
Application.ExportXML acExportTable, "System_User", _
   "c:\test.xml", , , , , , , adOtherTables

Anybody have experience export Access tables with so many levels?

Thanks
 
Solved it!

I did not realize you had to add Table3 to Table2 as a relationship. I thought Access could figure it out.

Anyway, here's the code if anyone wants to know how to do it.

Code:
Dim objInfo As AdditionalData
    
Set objInfo = Application.CreateAdditionalData
    
 With objInfo
        .Add "User_Org"
        objInfo("User_Org").Add ("Location_Privilege")
 End With
   
 Application.ExportXML ObjectType:=acExportTable, DataSource:="System_User", _
                          DataTarget:="C:\System_user.xml", _
                          AdditionalData:=objInfo
 

Users who are viewing this thread

Back
Top Bottom