![]() |
How to include field name in CopyFromRecordset
Hi all,
When I dump the record onto a sheet, I hope to include the fields' name from the recordset. How can I do it? Shu Zi Yang -- thank you so much for your help |
How to include field name in CopyFromRecordset
Can't.
Loop through the fields and stick the names above the recordset. Dim nFieldIndex as Long For nFieldIndex = 0 to rs.Fields.Count - 1 Cells(1, 1+nFieldIndex).Value = rs.Fields(nFieldIndex ).Name Next -- Tim Zych SF, CA "clara" wrote in message ... Hi all, When I dump the record onto a sheet, I hope to include the fields' name from the recordset. How can I do it? Shu Zi Yang -- thank you so much for your help |
How to include field name in CopyFromRecordset
Hi Tim,
If I want to chage some fields from number to descriptive string, how can I do it when I use CopyFromRecordset. For example, in filed Serverity 1 means "Low"; 2 means "Medium" Clara -- thank you so much for your help "Tim Zych" wrote: Can't. Loop through the fields and stick the names above the recordset. Dim nFieldIndex as Long For nFieldIndex = 0 to rs.Fields.Count - 1 Cells(1, 1+nFieldIndex).Value = rs.Fields(nFieldIndex ).Name Next -- Tim Zych SF, CA "clara" wrote in message ... Hi all, When I dump the record onto a sheet, I hope to include the fields' name from the recordset. How can I do it? Shu Zi Yang -- thank you so much for your help |
How to include field name in CopyFromRecordset
The query/stored proc should do it, IMO. I suppose you could perform a
find/replace to the results but my preference is to keep the logic in 1 place. -- Tim Zych SF, CA "clara" wrote in message ... Hi Tim, If I want to chage some fields from number to descriptive string, how can I do it when I use CopyFromRecordset. For example, in filed Serverity 1 means "Low"; 2 means "Medium" Clara -- thank you so much for your help "Tim Zych" wrote: Can't. Loop through the fields and stick the names above the recordset. Dim nFieldIndex as Long For nFieldIndex = 0 to rs.Fields.Count - 1 Cells(1, 1+nFieldIndex).Value = rs.Fields(nFieldIndex ).Name Next -- Tim Zych SF, CA "clara" wrote in message ... Hi all, When I dump the record onto a sheet, I hope to include the fields' name from the recordset. How can I do it? Shu Zi Yang -- thank you so much for your help |
All times are GMT +1. The time now is 10:26 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com