Library to Export tables as XML (1 Viewer)

kc1

Registered User.
Local time
Today, 03:09
Joined
Sep 22, 2008
Messages
23
Hi

I using the CreateAdditionalData method of exporting multiple tables as XML,

What reference(s) do I need to add?

Thanks
KC
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 18:09
Joined
May 7, 2009
Messages
19,231
see this:

Sub ExportXML(ObjectType As AcExportXMLObjectType, DataSource As String, [DataTarget As String], [SchemaTarget As String], [PresentationTarget As String], [ImageTarget As String], [Encoding As AcExportXMLEncoding = acUTF8], [OtherFlags As AcExportXMLOtherFlags], [WhereCondition As String], [AdditionalData])


Application.ExportXML

the function is in Access, no need to reference to other library.
 

Trevor G

Registered User.
Local time
Today, 11:09
Joined
Oct 1, 2009
Messages
2,341
You shouldn't need to add any additional references. I would ask which version of Access you are using. Can you show your complete code.

An example is shown below:

Sub ExportCustomerOrderData()
Dim objOrderInfo As AdditionalData
Set objOrderInfo = Application.CreateAdditionalData()
' Add the Orders and Order Details tables to the data to be exported. objOrderInfo.Add "Orders"
objOrderInfo.Add "Order Details"
' Export the contents of the Customers table. The Orders and Order
' Details tables will be included in the XML file.
Application.ExportXML ObjectType:=acExportTable, DataSource:="Customers", _ DataTarget:="Customer Orders.xml", _ AdditionalData:=objOrderInfo
End Sub
 

kc1

Registered User.
Local time
Today, 03:09
Joined
Sep 22, 2008
Messages
23
I'm using 2003 (company won't upgrade).
My code is very similar to what you posted.
The compile error is flagging up this line
Dim "objOtherTables as additionaldata"
 

Trevor G

Registered User.
Local time
Today, 11:09
Joined
Oct 1, 2009
Messages
2,341
Does your code actually have speech marks, if so remove them, else post all the code you are using, I can check it with a 2003 machine.
 

kc1

Registered User.
Local time
Today, 03:09
Joined
Sep 22, 2008
Messages
23
Does your code actually have speech marks, if so remove them, else post all the code you are using, I can check it with a 2003 machine.

'Private Sub btnExportXML_Click()
Dim objOtherTbls As additionaldata

Set objOtherTbls = Application.CreateAdditionalData
'Identify the tables or querys to export
objOtherTbls.Add "internet"
objOtherTbls.Add "mokaleme"
'Here is where the export takes place
Application.ExportXML ObjectType:=acExportTable, DataSource:="internet", DataTarget:="C:\myxml.xml", additionaldata:=objOtherTbls
MsgBox "Export operation completed successfully."'
 

Trevor G

Registered User.
Local time
Today, 11:09
Joined
Oct 1, 2009
Messages
2,341
I have just simulated your code in Access 2003 and it worked fine here is the copy of the code I ended up with. I placed it in a module sheet and used the same table name as yours but didn't see why you did a second objOthersTbls.Add which might have overwritten the other.

Code:
  Sub expXml()
  Dim objOtherTbls As AdditionalData
  Set objOtherTbls = Application.CreateAdditionalData()
  objOtherTbls.Add "internet"
  'Here is where the export takes place
  Application.ExportXML acExportTable, "internet", "C:\Access\MyXml.xml", AdditionalData:=objOtherTbls
   
  End Sub
 

kc1

Registered User.
Local time
Today, 03:09
Joined
Sep 22, 2008
Messages
23
I have just simulated your code in Access 2003 and it worked fine here is the copy of the code I ended up with. I placed it in a module sheet and used the same table name as yours but didn't see why you did a second objOthersTbls.Add which might have overwritten the other.

Code:
  Sub expXml()
  Dim objOtherTbls As AdditionalData
  Set objOtherTbls = Application.CreateAdditionalData()
  objOtherTbls.Add "internet"
  'Here is where the export takes place
  Application.ExportXML acExportTable, "internet", "C:\Access\MyXml.xml", AdditionalData:=objOtherTbls
 
  End Sub

Thanks, please could you tell me what Rferences you have checked?
I have Mircosoft XML, 6.0 checked.
 

Trevor G

Registered User.
Local time
Today, 11:09
Joined
Oct 1, 2009
Messages
2,341
I have no additional references checked, you shouldn't need to add any with this code. What happens if you remove the reference you checked.
 

kc1

Registered User.
Local time
Today, 03:09
Joined
Sep 22, 2008
Messages
23
I have no additional references checked, you shouldn't need to add any with this code. What happens if you remove the reference you checked.
Same error as before

Complile error:

User Defined type not defined
 

Trevor G

Registered User.
Local time
Today, 11:09
Joined
Oct 1, 2009
Messages
2,341
Then the only thing I can suggest is strip down a copy of your database (remove any sensitive data) and upload a copy into your thread.
 

kc1

Registered User.
Local time
Today, 03:09
Joined
Sep 22, 2008
Messages
23
Thanks for your help
I built a new database and the code now works.
 

Users who are viewing this thread

Top Bottom