I've been researching this issue high and low for an answer or at least a template to go by.
I am using MS Access 2007. I need to export a query as a text file with fixed width specifications (already done). The problem(s) I am running into, is that I must have a specific header and footer appended to the export. Header must have current date and trailer must have total items being exported.
I am admittedly in over my head, but usually can stumble along with some VBA code that does something similar.
Can anyone help?
There isn't any way to define extra lines of text in an export.
I assume you are using the TransferSpreadsheet Method to export your query in fixed-width format. That's typically the right approach for generating the fixed-width content, with or without field headers.
But if you want to add lines to the file before and after the data content, then you'll need to open the existing file, create a new file, append the header lines, then append the data from the existing file to the new file, and then append the footer lines, then close both files.
You could use the built-in VBA functions for working with files, but I find the Scripting.Runtime library offers more intuitive, object-oriented ways of working with files.
You'll need to add a reference to the Microsoft Scripting Runtime library in Tools.. References..