Unanswered: Can Access do this or have anyone tried this?
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!!
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 .