vba Access Excel SQL - Create Excel Header File

I am building a tool for a user who gets csv file report exports from a database, but they are missing the header row.  By header rows, I mean the first row of the excel/csv file that contains the field name/column name.  I'll call it a field name.

The same 50-100 reports export each day/week/month.  I've been asked to set up an MSAccess tool that will automate the function of inserting the field names.  I will need to store a header record (file? table?) of each report's field names. Each report has a unique number assigned that will be the link between the report and the header record. I'll build an entry form for creating a new header record, and for setting up the relationship link to it's report.  That's where it gets foggy. I can't save the header as a text field because it will often exceed the 255 char limit of this data type.  The my first ideas for how to proceed are:
 1) Have the user enter a row (in a unique table) for each column of the report.  Then save the header out as a unique table, probably using the report number for the table name.
2) Just like above, have the user enter a row for each column of the report, but then save it out to an excel file, with each row becoming a column in the excel file. Would make it easy for the next step of inserting it into the report.
3) Create and export a text file and save each column name with a delimiter comma.  Then call it up and read it back in with a loop to insert as field names.

I'd like to bounce this off someone to see if there is a better idea out there that I haven't considered.  Any thoughts?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

LambelAuthor Commented:
Where is everyone today? Company Xmas party??
Michael FowlerSolutions ConsultantCommented:
Some ideas

A generic excel document with the headers stored as a table on a work sheet. You could then write a macro that imports the required csv, adds the appropiate header and saves the new file. The beauty of this would be that multiple files could be processed similtanously as well as renaming the reports, adding formating, formulas and any other tweaks you can think of.

Instead of having a unique table for each report, why not use one table and have a field for report name/number and then fields for header1, header2 etc. From there it should not be hard to extract a csv string of the header for each report.

Have you looked into the reason why the headers are missing? It may beeasy to just have the extraction add these headers.

LambelAuthor Commented:
Michael: Thanks for your reply.
I didn't mention that the user wants to be offered a list of reports with checkboxes that can be selected for all the reports (multiple at the same time) that would be reformated.  There will be a table in the Access database that will hold the source csv file of the report and the header file. To put them together, a routine will open a new excel file, insert the header (which is row 1), and then (using a loop) insert all the rows of data from the csv file and save it out to a specified folder.
Also - the option of fixing the export was shot down.
The 7 Worst Nightmares of a Sysadmin

Fear not! To defend your business’ IT systems we’re going to shine a light on the seven most sinister terrors that haunt sysadmins. That way you can be sure there’s nothing in your stack waiting to go bump in the night.

LambelAuthor Commented:
I mis-spoke:  There will be a table in the MSAccess database that will hold the LOCATION of the source csv file (not the csv file).
Michael FowlerSolutions ConsultantCommented:
I would definately use my first solution.
The front page(or userform set to open on workbook open) would hold the check list, a hidden sheet would hold the headers.
Then for each selected report

Create a new sheet
Insert the appropiate header
Get CSV location
Open CSV
Insert Data into new sheet
Format sheet
Save sheet as new workbook in required location with appropiate name


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
LambelAuthor Commented:
thanks for your suggestions. I preferred to build this in access, so I am using a table to hold the header records.  I will build the table as illustrated:
ReportID      HeaderField     SortOrder
001             xxx                    20
001             yyy                    10
001             aaa                    15
002             111                    10
003             111                    20
I should have thought of this, but I didn't.  Either way, this will work well with my design.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Applications

From novice to tech pro — start learning today.