marku24
asked on
Eporting Access Query o Excel
I am using the following code to export an Access query to Excel:
Set sht = wbk.Sheets.Add
sht.Name = "Cost Data"
Set rs = CurrentDb.OpenRecordset("s qryExportT oAdmin_Cos tDetails", , dbFailOnError)
sht.Range("A2").CopyFromRe cordset rs
I would like the heading of the query to appear on row 1, is there a parameter I can turn on to include field headings?
Set sht = wbk.Sheets.Add
sht.Name = "Cost Data"
Set rs = CurrentDb.OpenRecordset("s
sht.Range("A2").CopyFromRe
I would like the heading of the query to appear on row 1, is there a parameter I can turn on to include field headings?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thank you, works perfectly.
' Copy field names to the first row of the worksheet
fldCount = rst.Fields.Count
For iCol = 1 To fldCount
xlWs.Cells(1, iCol).Value = rst.Fields(iCol - 1).Name
Next
OM Gang