Link to home
Start Free TrialLog in
Avatar of DataTrain
DataTrainFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Using Access VBA to write table data to an XML file

I want to click a button in Access and output a Table (or data from a Query) to an XML file. I have tried successfully doing this via the GUI but I need to do it in VBA. This would need to work in 2003 as well as 2007. I will also need to EITHER specify san existing XML file and location OR create a new XML file in a specific location. A brief code example would be really helpful. Thanks.
Avatar of Jez Walters
Jez Walters
Flag of United Kingdom of Great Britain and Northern Ireland image

You should be able to achieve what you're after by creating an ImportExportSpecification on the fly, and then executing it.

If you supply a sample database, I'd be happy to show you how to do this.
ASKER CERTIFIED SOLUTION
Avatar of Jez Walters
Jez Walters
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DataTrain

ASKER

That works OK. Thanks.
Glad I could be of assistance!  :-)

I take it you managed to work out how to check for an existing XML file/location then?
No actaully! I am just looking at the feasability of doing some work involving XML which I have never used before. I would need to get into the details of the code but I was just trying to get a feel for how easy it is to export some tables. However, any other hints you may want to offer will be greatfully received!
You can use the Dir() function to test whether a given file/directory exists - hope that helps!  :-)
This is a very long short - but I had a friend living in London called James Walters. In the unlikely event that was you, you would know where "The Freddy" was! Anyway, this isn't lost friends, so thanks for your help.
No relation, I'm afraid!  :-)