Exporting a query to XML

D

drew

Hi. I have a module with a short Sub to 1) make a recordset from a
query, then 2) save the query to an XML flat file. I call the Sub from
a control button on a form, passing the file and query name to the sub.

It works great for many of my queries, but for a few queries no records
are included in the XML file - just a 1 KB file with the header
information. I have opened all of the queries in display view, and
they display fine. It is not a spelling problem since the header in
the xml file contains the right field definitions. The code is
below...any ideas? I am stumped.
____________________________________________

Public Sub Create_xml(strFileName, strQryName)
Dim conn As New ADODB.Connection
Dim rst As New ADODB.Recordset

Set conn = Application.CurrentProject.Connection
With rst
.Open strQryName, conn, adOpenDynamic, adLockOptimistic
.Save strFileName, adPersistXML
.Close
End With
Set rst = Nothing
Set conn = Nothing
End Sub
_______________________________________________


Thanks!
Drew
 

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