Link to home
Start Free TrialLog in
Avatar of FrankLu
FrankLu

asked on

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

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

ASKER CERTIFIED SOLUTION
Avatar of effes
effes
Flag of Germany 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 FrankLu
FrankLu

ASKER

Hi Effes,

Thank you for your reply. It worked fine.
Best regards
Frank
You're welcome.