Results 1 to 4 of 4
  1. #1
    InuYasha64's Avatar
    InuYasha64 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2012
    Location
    Dallas, TX
    Posts
    2

    Question Exporting multiple tables/queries to XML Access 2010

    I'm hoping someone can help me understand why my code is not functioning correctly.

    Here is the code:
    Code:
    Public Function XML_OutSendBtn_Click()
    'export query to selected XML file
        Dim ExportFileStr As String
        Dim objAddress As AdditionalData
        
        ExportFileStr = "C:\Users\Admin\Desktop\Test"
        Set objAddress = Application.CreateAdditionalData
            
        If Right(ExportFileStr, 4) <> ".xml" Then
            ExportFileStr = ExportFileStr & ".xml"
        End If
        
        Set objAddress = objAddress.Add("EMPADDRESS")
        objAddress.Add ("EMPADDRESS")
        
        Application.ExportXML acExportQuery, "EMPLOYEE", ExportFileStr, , , , , , , objAddress
    End Function
    What happens is that I had to put the Employee Address query in twice "EMPADDRESS" for it to show up on the output XML file. I don't think that I should have had to resort to that for it to work. I'm calling this in a macro and the macro is being called by a command button on a form. I borrowed this code from another post that was solved last year.

    Any suggestions would be appreciated.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,944
    So it works?
    This article has example code that does the same thing, except sets two AdditionalData variables.
    http://msdn.microsoft.com/en-us/libr...ffice.11).aspx
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    InuYasha64's Avatar
    InuYasha64 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2012
    Location
    Dallas, TX
    Posts
    2
    June7,
    Yes, the code works, but not correctly.
    I tried the MS code before I found the one posted on this forum from last year.

    The MS code did not work for me.
    The specific part that breaks is the "Application.ExportXML" portion. That is why I used the code I have listed in my first post.

    Beyond just this part, I am attempting to have MS Access handle generating a Parent-Child node set in the XML output.

    Any suggestions?
    Here is what the XML output needs to look like:
    Code:
    <Parent>
          <Child1>
              <SomeData></SomeData>
          </Child1>
          <Child2>
              <SomeData></SomeData>
          </Child2>
    </Parent>
    I can get the Child1 and Child2 outputs from the code in my first post, but I really need it to output the way I have shown here.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,944
    Seems I've seen this topic before, long time ago. My recollection is the Export method can't do that and testing I just did supports conclusion. Each table is exported sequentially into the xml file. You can join EMPLOYEE and EMPADDRESS into a query and export that query but still don't get the structure you want. I think in the other thread poster was resigned to writing custom code to build a text file, line by line, to get what they wanted.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 01-10-2012, 10:12 PM
  2. Exporting access 2010 to SQL db
    By jscriptor09 in forum Programming
    Replies: 0
    Last Post: 11-29-2011, 09:50 PM
  3. Queries with multiple tables to create report
    By Solstice in forum Queries
    Replies: 1
    Last Post: 09-22-2011, 02:23 PM
  4. Replies: 7
    Last Post: 08-05-2011, 10:59 AM
  5. Exporting Access queries to Excel
    By dbDamo in forum Import/Export Data
    Replies: 2
    Last Post: 09-22-2009, 01:42 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums