Solved

How to write a recordset with Access VBA in an XML file

Posted on 2011-09-06
3
389 Views
Last Modified: 2013-11-25
Dear all
I try to write a record or recordset to an empty XML File.
This is my code. But I get run-time error 424.
I would appreciate some help.
Thanks in advance.
Best regards
Frank
 
Sub Write_Recordset_toXMLFile()

Dim strSQL As String
Dim file_name As String
Dim rst As ADODB.Recordset

Set rst = New ADODB.Recordset

    file_name = "C:\Development\Access\Test\xml_test.xml"
    rst.ActiveConnection = CurrentProject.Connection
    strSQL = "SELECT tblLink.ID, tblLink.Frontend, tblLink.FrontendPath FROM tblLink WHERE (((tblLink.ID)=1));"
    rst.Open strSQL

    rs1.Save "file_name", adPersistXML  'Run-Time error '424'

End Sub

Open in new window

0
Comment
Question by:FrankLu
  • 2
3 Comments
 
LVL 6

Accepted Solution

by:
effes earned 500 total points
ID: 36490616
Hi Frank,

I'm don't use VBA too often, but I noticed two things in your code:
1. If it isn't just a typo in your post, try changing "rs1.Save" at the beginning of line 14 to "rst.Save".
2. Remove the quotes around file_name on the same line. The way you're doing it passes the string "file_name" to the function and not the value of the variable file_name.

Line 14 should be like this:

 rst.Save file_name, adPersistXML

I hope that helps,
Frank
0
 

Author Comment

by:FrankLu
ID: 36490783
Hi Effes,

Thank you for your reply. It worked fine.
Best regards
Frank
0
 
LVL 6

Expert Comment

by:effes
ID: 36491544
You're welcome.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This very simple solution applies to a narrow cross-section of the "needs to close" variety. In this case, the full message in Event Viewer was in applog, Event ID 1000: Faulting application iexplore.exe, version 8.0.6001.18702, faulting module …
We were having a lot of "Heartbeat Alerts" in our SCOM environment, now "Heartbeat" in a SCOM environment for those of you who might not be familiar with SCOM is a packet of data sent from the agent to the management server on a regular basis, basic…
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now