How to export a table to a text file using different export specifications

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rachapinky
    New Member
    • Apr 2010
    • 2

    #1

    How to export a table to a text file using different export specifications

    I need to export 2 tables to the same text file.
    The 2 tables must be exported using different export specifications to the same text file --> the file must be cumulative.
    Can I do this in Access??? If yes, advise how to do it.
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    Originally posted by rachapinky
    I need to export 2 tables to the same text file.
    The 2 tables must be exported using different export specifications to the same text file --> the file must be cumulative.
    Can I do this in Access??? If yes, advise how to do it.
    I don't think that you can do this, but what you can do is to Export the 2 Tables separately with their own Export Specs, then concatenate them into what the Original File Name should be, namely:
    1. Export Table1 as Table1.txt
    2. Export Table2 as Table2.txt
    3. Concatenate both Text Files into a Single File
    4. Assuming that you are executing this Line of Code from the same Folder where both Files exist:
      Code:
      Copy Table1.txt + Table2.txt Table3.txt
    5. The contents of Table2.txt will be added to the contents of Table1.txt and can be viewed in Table3.txt

    Comment

    • rachapinky
      New Member
      • Apr 2010
      • 2

      #3
      Originally posted by ADezii
      I don't think that you can do this, but what you can do is to Export the 2 Tables separately with their own Export Specs, then concatenate them into what the Original File Name should be, namely:
      1. Export Table1 as Table1.txt
      2. Export Table2 as Table2.txt
      3. Concatenate both Text Files into a Single File
      4. Assuming that you are executing this Line of Code from the same Folder where both Files exist:
        Code:
        Copy Table1.txt + Table2.txt Table3.txt
      5. The contents of Table2.txt will be added to the contents of Table1.txt and can be viewed in Table3.txt
      thank you very much for your answer.
      can this concatenation be done using a query or a module in access???

      Comment

      • ADezii
        Recognized Expert Expert
        • Apr 2006
        • 8834

        #4
        Originally posted by rachapinky
        thank you very much for your answer.
        can this concatenation be done using a query or a module in access???
        This can be done in VBA code immediately after the Exports of the 2 Reports, but I am going out for the evening. Will show you how it is done tomorrow,

        Comment

        • ADezii
          Recognized Expert Expert
          • Apr 2006
          • 8834

          #5
          Let's assume that both Reports were Exported to the C:\Reports\ Folder as 1.txt and 2.txt consecutively. To concatenate the results of both Reports to a single File named 3.txt, in the same Folder:
          Code:
          Dim retVal
          
          retVal = Shell("cmd /c Copy C:\Reports\1.txt + C:\Reports\2.txt C:\Reports\3.txt", vbMinimizedNoFocus)

          Comment

          Working...