access 2002 exportXML method bug

J

jeff maultby

Hi
Found bug with ExportXML method when query is used to
populate form. Can anyone help with a fix please?

To reproduce please do the following:
Access 2002

Create new db

Create 2 simple master detail tables, use the wizards for
contacts &
orders, relate orders to contacts via contact id. Contact
tabel has ContactID, firstname, lastname. Orders table
has OrderID, ContactID, PurchaseOrderNumber.

Create 2 forms for each table, use the wizards.

Add command button to contact form. In command button
code add
"DoCmd.OpenForm Orders".

Add query named "Orders Query" with content of
SELECT Orders.OrderID, Orders.ContactID,
Orders.PurchaseOrderNumber
FROM Orders
WHERE Orders.ContactID=Forms!Contacts!ContactID;

In Record Source properties of Orders form select "Orders
Query".

Run Contacts form and see that orders form opens and
shows only those
orders for the current contact in the contact form.

Add command button to orders form labelled "Export XML"
and named
cmdExportXML.

In code for cmdExportXML button add
"Application.ExportXML
acExportForm, "Orders", "Orders.xml","Orders.xsd", "Orders
..xsl"

Run contacts form, click orders button, click Export XML
button and note
that a dialog opens asking for Forms!Contacts!ContactID

This does not happen with the form. Neither does it
happen with OutputTo
method which correctly generates XLS, RTF etc without
prompting.

I have a very small access 2002 mdb file which replicates
this problem, if u wish it please email me.

Jeff
 
J

John Viescas

Jeff-

None of the export facilities have ever worked with parameter queries.
Access runs them directly in JET, and the database engine cannot "see" the
UI to resolve your parameter, so you get prompted for it. The only solution
is to edit the form's design and set the Record Source to SQL that includes
the parameter just prior to exporting it. Note that you can open a form in
Design View hidden so the user doesn't see you dinking with it.

--
John Viescas, author
"Microsoft Office Access 2003 Inside Out"
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
http://www.viescas.com/
(Microsoft Access MVP since 1993)
http://www.deanforamerica.com/site/TR?pg=personal&fr_id=1090&px=1434411
 
J

jeff maultby

thanks very much indeed, great idea.
i've built the child form's recordsourc sql in the
parent's current event and the child's open event. seems
to work great.
Problem i now get is with bug in resultant xml/html.
Openeing in IE6 it gives:
A runtime error has occurred.
Line 19
Error Microsoft VBScript runtime error
Object required: 'GetValue(...)'
line=1, col=0 (line is offset from the start of the
script block.
Error returned from property or method call
Any pointers?
regards
Jeff
 

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

Top