Export to csv with headers

W

Webtechie

Hello,

I've created some code to export some SQL to a csv file.

Now, I am told, the file should have the headers in the first row.

How do you add headers? Here is the code so far:

On Error Resume Next
' is run for the first time
With CurrentDb ' it would be better to check to see if the
' querydef exists and then delete it
.QueryDefs.Delete ("ExportFile")
' createquerydef command line follows
Set qdf = .CreateQueryDef("ExportFile", strSQL)
.Close
End With

Set qdf = Nothing

BatchFile = mCorpID & "_" & mAgentID & "_" & BatchMonth & BatchDay &
BatchYear & ".csv"
BatchFileName = ImportFolder & "\" & BatchFile

DoCmd.TransferText acExportDelim, "TempBatchFile Export_Spec", "ExportFile",
BatchFileName
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top