Results 1 to 4 of 4
  1. #1
    Join Date
    May 2006
    Location
    NYC
    Posts
    30

    Cool Unanswered: Can Access do this or have anyone tried this?

    Hi,

    Is there a way to export a table/query to an CSV file and add a header and a trailer records to the file? If so, can someone give me some ideas on how I can do this? Much Appreciated for any assistance here!!

    Wendy

  2. #2
    Join Date
    Feb 2004
    Location
    Chicago, IL
    Posts
    1,312
    You will have to do it using VBA. Access will export a file to a CSV, but there is no way I know of to get a header record and trailer record in the file (I am assuming the Header and Trailer have different number of fields than the detail records).

    The only way I can think of doing it would be to have a query that creates the Header, one for the Detail and one for the Trailer. If the trailer and Header have a different number of fields then add some extra blank fields to the query. Then use a UNION query to gather all of the records from the three queries. You will also want to add a Record Type field and use something like 0 for Header, 1 for Detail and 99 for Trailer. Then export the UNION query.

    The other way, with VBA, you will want to check the help for the Open function, the FreeFile function, Kill procedure, Close procedure .

  3. #3
    Join Date
    May 2006
    Location
    NYC
    Posts
    30
    Thanks DC for the reply!! I will try your easy way first and let you know.

  4. #4
    Join Date
    Dec 2006
    Posts
    2

    An Interesting Solution

    Hi All,

    You could create a Union Query.

    In Query SQL View

    Select "First Name" as Field1, "Middle Name" As Field2, "Last Name" As Field3
    From tblNames;
    UNION
    Select Field1, Field2, Field3
    From tblNames;


    This will introduce a header record above the data. You can then outputTo the query to CSV file.

    Not pretty but might do the trick

    Pippin

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •