Currently, I am using Access 2010. I have used TSQL to create and store several pass-through queries.
Before, I was using the following VBA to export native (to Access 2010) "select" queries on a regular basis:
Sub ExportToXmlFile()
Application.ExportXML ObjectType:=acExportQuery, DataSource:="Query1", DataTarget:="C:\Desktop\Query1.xml"
Application.ExportXML ObjectType:=acExportQuery, DataSource:="Query2", DataTarget:="C:\Desktop\Query2.xml"
End Sub
However, ever since I reworked Query1 and Query2 as pass-through queries, I receive the following run-time error: "7798: You can only save select, crosstab, and union queries to this format".
Therefore, I would like to know how I can rewrite the aforementioned VBA in order to be able to export my pass-through queries as XML files?
Notes:
I stumbled upon the following during my research on this problem: Can't export a pass through query...Google groups
It seems like a possible solution is to store the pass-through query as a temporary table, and then export the temporary table as an XML file. Unfortunately, I have been trying to rewrite the VBA above to do so, to no avail.
You discovered ExportXML
will not accept a pass-through query. However, at least in Access 2007, you can work around that limitation fairly easily by creating a new query which uses the pass-through as its data source. Then ExportXML
will accept the new query without complaint.
Create and save this query as qryFromPassthru :
SELECT *
FROM Query1;
Then use qryFromPassthru with ExportXML
:
Application.ExportXML ObjectType:=acExportQuery, _
DataSource:="qryFromPassthru", DataTarget:="C:\Desktop\Query1.xml"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.