Results 1 to 7 of 7
  1. #1
    SteveF is offline Generally AccessAble
    Windows XP Access 2010 32bit
    Join Date
    Nov 2010
    Location
    Fourth Corner
    Posts
    123

    Multiple table XML export

    I have an application which imports and exports data sent from/to a major client. The client sends their data in XML format, and I return data the same way using Application.ExportXML

    Until now, I've just exported the contents of a single table to the XML file, and it's worked well. However, the client now wants to receive one XML file that contains the contents of two tables in the application.

    According to Access Help, this is theoretically possible. However, my attempts to follow the directions to do this have been less than fruitful. The uncertainty I have is in exactly how to populate the "AdditionalData" parameter which is supposed to handle adding the second table to the XML file.

    Any assistance would be appreciated.
    TIA,


    Steve

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Why is it not working - error message, nothing happens, wrong results? Post your code for analysis.

    Third time's a charm, got my test to work. Exported 4 tables.
    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
    SteveF is offline Generally AccessAble
    Windows XP Access 2010 32bit
    Join Date
    Nov 2010
    Location
    Fourth Corner
    Posts
    123
    Quote Originally Posted by June7 View Post
    Why is it not working - error message, nothing happens, wrong results? Post your code for analysis.

    Third time's a charm, got my test to work. Exported 4 tables.
    Wrong results: Only the data supplied by the query specified in the DataSource parameter is included in the XML file. What's unclear to me is the specific way to include additional tables -- the example in MS Access Online Help is not consistent or specific enough for me to make sense of it.

    Would you please post your test code?

    Thanks,
    Steve

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    It is the same as found at http://msdn.microsoft.com/en-us/library/ff193212.aspx

    When I succeeded with 3 tables per the example I included another .Add line to get 4th table.

    Post your code for analysis.
    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.

  5. #5
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Hey June7 thanks for the link. I have acc2003 on XP.
    I could never get Access to export multiple files (although it was more of a test once or twice than serious work), but this example worked. I also added a 4th table as you did in your test. Worked well.

    I'm not sure what I'd really use it for. I'm not sure how to read the xml -- any suggestions.. links.. samples?? I did do something a few years ago, when working, to get some xml from website, then use some vba code and (I think xmlspy 2005 or so) to convert the xml to some .txt files for import into access. Hokey, but it solved an issue at the time.
    Last edited by orange; 07-14-2011 at 05:01 AM.

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    The only thing I know xml files are good for is loading data to web pages with html code. I am sure you could google 'what is xml file' and get clues on how to read them, try Wiki.
    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.

  7. #7
    SteveF is offline Generally AccessAble
    Windows XP Access 2010 32bit
    Join Date
    Nov 2010
    Location
    Fourth Corner
    Posts
    123
    Quote Originally Posted by June7 View Post
    It is the same as found at http://msdn.microsoft.com/en-us/library/ff193212.aspx

    When I succeeded with 3 tables per the example I included another .Add line to get 4th table.

    Post your code for analysis.
    Well, it's working now; here's the code that works, thanks to another source of assistance:

    Code:
    Private Sub XML_OutSendBtn_Click()
    'export query to selected XML file
        Dim ExportFileStr As String
        Dim objSchedule As AdditionalData
        
        ExportFileStr = XML_PathEdit
        Set objSchedule = Application.CreateAdditionalData
        
        If Right(ExportFileStr, 4) <> ".xml" Then
            ExportFileStr = ExportFileStr & ".xml"
        End If
        
        Set objSchedule = objSchedule.Add("NCOA_MatchTbl")
        objSchedule.Add ("attend_schedule")
        
        Application.ExportXML acExportQuery, "AddressUpdateReturn", ExportFileStr, , , , , acEmbedSchema, , objSchedule
    
    End Sub
    What was not to me clear from Online Help (and MSDN, which has the same information) was that EVERY TABLE containing data that is to be included must be included in the AdditionalDataObject.Add sequence.

    <EDIT> FWIW, XML files are being used in this scenario to transfer data files to & from our site and our client's site(s). XML was selected as a "common" format understood and importable/exportable by the two different systems in use in our respective locations.

    Steve

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

Similar Threads

  1. Export multiple records based on a field
    By dskulman in forum Import/Export Data
    Replies: 0
    Last Post: 03-03-2011, 02:44 PM
  2. export multiple reports based on table records
    By steve2000 in forum Reports
    Replies: 3
    Last Post: 10-03-2010, 03:44 PM
  3. export table to multiple sheets
    By TheShabz in forum Import/Export Data
    Replies: 5
    Last Post: 04-06-2010, 02:59 PM
  4. export report to multiple tabs
    By mws5872 in forum Import/Export Data
    Replies: 0
    Last Post: 06-30-2009, 03:07 PM
  5. export to multiple sheets based on change in sort
    By mws5872 in forum Programming
    Replies: 0
    Last Post: 06-30-2009, 07:55 AM

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