Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA button to export MS Access 2k Db to XML

Status
Not open for further replies.

hotreca

Technical User
Nov 19, 2002
25
0
0
DE
[thumbsup]Hi
here my prolem.
I'm trying to export an Access qry to XML by the push of a button now I have a code put it does not only export the XML data but also the Schema .xsd which complicates matters and makes it difficult to proccess this data. further I get the compile error message 'Named argument not found'
below the code I used:


Private Sub btn_XMLExport_Click()
Application.ExportXML _
ObjectType:=acExportTable, _
DataSource:="qry_name", _
DataTarget:="d:\xmlData\qry_name.xml", _
SchemaTarget:="d:\xmlData\qry_name.xsd", _
SchemaFormat:=acSchemaXSD, _
OtherFlags:=1
MsgBox "XML Export complete!!", vbInformation
End Sub


Did I forget something?
What can I still check?

Any help would be appreciated.

Greetings
hotreca[thumbsup]
 
Isn't the object type a query:
[tt]
ObjectType:=acExportQuery
SchemaFormat:=acSchemaNone 'no schema
[/tt]
I haven't tried exporting to XML but will be doing it soon - hence i'm interested on how you get on :). The other way to export is to save an ADO recordset by invoking the save method e.g.
[tt]
rs.Save strFileName, adPersistXML
[/tt]

Cheers,
Dan
 
[2thumbsup]Thanks [2thumbsup]
for the answer but that does not do it either but the problem is that VBA does not recognize 'SchemaFormat' do I need to declare it

Further could you give me the whole or a sample script for the ADO recordset.

To your question the easiest way to export as .xml is to highlight the table/query/report or form press File-export an choose the ending .xml

greetings
hotreca
 
hmmm, I can't get it to work either - try deleting it and see what happens.

Here's an ADO XML export example:
[tt]
Public function ExportXML()
dim rs as adodb.recordset

set rs = new adodb.recordset

rs.open "SELECT * FROM myQuery", currentproject.connection
rs.save "d:\myQuery.xml", adpersistxml
rs.close

set rs = nothing

exit function
[/tt]

The output file includes both schema and data, so its probably not what you want. However, you can retreive the xml file with ado e.g. [tt]rs.open "d:\myQuery.xml"[/tt]

Cheers,
Dan
 
Seems like I saw something in Access Advisor a while ago about this.

Good Luck!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top