copying field names from Access query

M

mike.wilson8

In the code below, the field names from the query start on row 9, col
A. How do I tweak the code to where the field name header section
starts on row 9, col F?


Set qry = db.QueryDefs("Q-PRE_ENDTOEND_CROSSTAB BY DAY")
Set rec = qry.OpenRecordset
Sheets("Sheet1").[f10].CopyFromRecordset rec

' Set up column headers with field names
For i = 0 To rec.Fields.Count - 1
Cells(9, i + 1).Value = rec.Fields(i).Name
' Cells(9, i + 1).Font.Bold = True
 
D

Dave Patrick

Change + 1 to + 6

--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

| In the code below, the field names from the query start on row 9, col
| A. How do I tweak the code to where the field name header section
| starts on row 9, col F?
|
|
| Set qry = db.QueryDefs("Q-PRE_ENDTOEND_CROSSTAB BY DAY")
| Set rec = qry.OpenRecordset
| Sheets("Sheet1").[f10].CopyFromRecordset rec
|
| ' Set up column headers with field names
| For i = 0 To rec.Fields.Count - 1
| Cells(9, i + 1).Value = rec.Fields(i).Name
| ' Cells(9, i + 1).Font.Bold = True
|
 

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