Export to csv with headers

  • Thread starter Thread starter Webtechie
  • Start date Start date
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
 
Back
Top