Exporting table data from a form to xml

Jdreyfus

Registered User.
Local time
Yesterday, 17:16
Joined
Jun 19, 2008
Messages
27
I'm curious if any of you have come accross a code that will output to an xml file the contents of a form?

I found this:

Code:
[FONT=Times New Roman][SIZE=3]Dim oXML As New clsXMLExport[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]Dim oRS As adodb.Recordset[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]Dim oConn As New adodb.Connection[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]Dim sSQL As String[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]Dim oCmd As New adodb.Command[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]Dim sConnString As String[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]sConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\mydatabase.mdb"[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]oConn.ConnectionString = sConnString[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]oConn.Open[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]sSQL = “SELECT * FROM MYTABLE”[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]set oCmd.ActiveConnection = oConn[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]oCmd.Command[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]oCmd.CommandText = sSQL[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]oCmd.CommandType = adCmdText[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]set oRS = oCmd.Execute[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]oXML.OutputFile = "C:\MyXMLFile.xml"[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]Set oXML.CurrentRecordset = oRS[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]oXML.TagStart "MyTable"[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]oXML.AddRecordset[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]oXML.TagEnd[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]oXML.PersistXML[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]oRS.Close[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]set oXML = Nothing[/SIZE][/FONT]


But I don't know if it's even remotely what I'm looking for. I don't know enough about vb to know whether this will do what I want, and it's in ADO (I'm guessing) so I'm not sure if there's something I need to change in my vb references in order to use the code properly. The instructions I recieved from where I found it were less than forthcoming. Anyone have any idea how to work with exporting to xml?
 
what you mean by contents of a form?

Do you mean the data displayed on the form, or do you mean the Recordset behind the form?
 
The data displayed on the form. I've tried the access export as xml option and it ends up creating an xml document with all the records from the table the form is working off of. I need only one at a time.
 

Users who are viewing this thread

Back
Top Bottom