ExportXML File Format Problem

G

Guest

I'm generating an XML file to be imported into an accounting program using a
COM object that reads XML files. The </TRANSACTION> (end transaction) should
show up after the Detail, Payment, and Tax sections but appears before the
first Detail section. I do not understand why this is happening and if there
is an error in my code. Below you will find the code I use and the resulting
XML file. Please help me understand what I need to do to get the Detail,
Payment and Tax sections inside of the Transaction section where they belong.
With this problem those sections are not being imported and therefore I do
not have correct transactions.
Thank you.
Ted

Access 2003 VBA Module:
'Export data to XML file
Dim objOrderInfo As AdditionalData
Set objOrderInfo = Application.CreateAdditionalData
'Add the orders and order details and order totals data to be exported
objOrderInfo.Add "DETAIL"
objOrderInfo.Add "PAYMENT"
objOrderInfo.Add "TAX"

'Generate XML file
Application.ExportXML acExportTable, _
DataSource:="TRANSACTION", _
DataTarget:="C:\AccountsReceivable.xml", _
AdditionalData:=objOrderInfo

'Import XML file using the TPCOM object
Dim oAR As TPCOM.TPAR
Set oAR = New TPCOM.TPAR

If oAR.Session.Active Then
If Not oAR.EnterTransaction("C:\AccountsReceivable.xml") Then
MsgBox "Failed to Enter XML Transaction for Order # " &
CRS1.Fields("OrderID")
Else
intRecProcessed = intRecProcessed + 1
End If
Else
MsgBox "You need to have Turning Point installed and running."
End If
If oAR.LastErrorXML <> "" Then
MsgBox oAR.LastErrorXML, vbInformation, "XML Process"
End If
Set objOrderInfo = Nothing

The XML File:
<?xml version="1.0" encoding="UTF-8"?>
<dataroot xmlns:blush:d="urn:schemas-microsoft-com:blush:fficedata"
generated="2005-10-27T11:06:12">
<TRANSACTION>
<CUSTOMER>BellGraph </CUSTOMER>
<DESCRIPTION>Order # 3553</DESCRIPTION>
<DATE>10/26/2005</DATE>
<DOCNO>3553</DOCNO>
<MISCAMOUNT>0</MISCAMOUNT>
</TRANSACTION>
<DETAIL>
<DESCRIPTION>#3 Overbox Crate Cut Sheet</DESCRIPTION>
<UNITPRICE>70.2144</UNITPRICE>
<ORDERQTY>1</ORDERQTY>
<TOTALPRICE>70.2144</TOTALPRICE>
<SALESCATEGORY>AR</SALESCATEGORY>
<TAXABLE>False</TAXABLE>
<TAXGROUP>MN</TAXGROUP>
</DETAIL>
<DETAIL>
<DESCRIPTION>1 X Cutsheet</DESCRIPTION>
<UNITPRICE>70.176</UNITPRICE>
<ORDERQTY>1</ORDERQTY>
<TOTALPRICE>70.176</TOTALPRICE>
<SALESCATEGORY>AR</SALESCATEGORY>
<TAXABLE>False</TAXABLE>
<TAXGROUP>MN</TAXGROUP>
</DETAIL>
<PAYMENT>
<DOCNO>0</DOCNO>
<DATE>2005-10-26T00:00:00</DATE>
<DESCRIPTION>Order # 3553 To Joe&apos;s Antiques </DESCRIPTION>
<AMOUNT>0</AMOUNT>
</PAYMENT>
<TAX>
<CODE>MN</CODE>
<TAXABLESALES>140.3904</TAXABLESALES>
<NONTAXABLESALES>0</NONTAXABLESALES>
<AMOUNT>12.4947</AMOUNT>
</TAX>
</dataroot>
 
J

Joe Fallon

Ted,
The code looks right.

Try exporting the Transaction table using the menu functionality.
File, Export...
As XML

Then choose the other 3 tables as additional data.

1. Is the XML file the way you expect it to be?

Then setup 2 tables in a formal 1 to many relationship and add a few rows of
data to each.
Then export them.
2. Is this XML file "nested" correctly?
(My tables seem to nest correctly.)

Perhaps the problem is there is no formal relationship between your tables?
 
Top