Exporting linked tables to XML

S

Stephen English

I have a customer order system for a timber company. Table POS_1 is all the
customer information, POS_2 is the product information for each item in the
order and POS_3 is the tally (qty at each length) for the product.

THis code works fine but is like a flat file and there is a lot of
duplication of data in first two tables

strSQL = "SELECT POS_1.QuoteNo, POS_1.CustNo, POS_1.CustName, POS_1.PhoneNo,
POS_1.Add1, POS_1.Add2, " & _
"POS_1.Add3, POS_1.Pcode, POS_1.dis_cd, POS_1.Date, POS_1.Current,
POS_1.DelFee, POS_PMethods.Payment, " & _
"POS_1.PMethod, POS_1.OrderType, POS_1.Comment, POS_2.itnbr,
POS_2.itemno, POS_2.Desc12, POS_2.totqty, " & _
"POS_2.price, POS_3.qty, POS_3.length, [totqty]*[price] AS Exttotal,
POS_2.Comment, 'Order' AS Type, " & _
"'These prices are inclusive of GST' AS GST " & _
"FROM ((POS_1 INNER JOIN POS_2 ON POS_1.QuoteNo = POS_2.QuoteNo)
INNER JOIN POS_3 ON " & _
"(POS_2.itemno = POS_3.itemno) AND (POS_2.itnbr = POS_3.itnbr) AND
(POS_2.itnbr = POS_3.itnbr) " & _
"AND (POS_2.QuoteNo = POS_3.QuoteNo)) LEFT JOIN POS_PMethods ON
POS_1.PMethod = POS_PMethods.PMethod " & _
"WHERE POS_1.QuoteNo=" & lngQN
End If
'Delete old query first - we want fresh data!
db.QueryDefs.Delete strQueryName
'Create query definition
Set qryDef = db.CreateQueryDef(strQueryName, strSQL)
Application.ExportXML ObjectType:=acExportTable, DataSource:=strQueryName, _
DataTarget:="S:\POSQuoteExportFiles\" & lngQN &
".xml"


I would like to generate XML that looks like
<Order><!--POS_1-->
<CustName>Fred</CustName>
<Tel>1234 5678</Tel>
etc
<Product><!--POS_2-->
<Code>ABC123</Code>
<Desc>042x019 Pine</Desc>
<Tally><!--POS_3-->
<Qty>1</Qty>
<Len>3.3</Len>
</Tally
<Tally>
<Qty>1</Qty>
<Len>4.2</Len>
</Tally
</product>

<Product><!--POS_2-->
<Code>ABC124</Code>
<Desc>070x019 Pine</Desc>
<Tally><!--POS_3-->
<Qty>1</Qty>
<Len>1.5</Len>
</Tally
<Tally>
<Qty>1</Qty>
<Len>3.6</Len>
</Tally
</product>
</Order>

Any ideas please?
Stephen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top