OpenRecordSet

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

How can I bring in the Field Names or Column Titles into
Excel when using the OpenRecordSet method to import a
table from Access to Excel? Currently it only brings in
the records.

Current Code:

Set dba = OpenDatabase("C:\file.mdb", False,
False, ";pwd=password")
Set rst = dba.OpenRecordset("Table", dbOpenDynaset,
dbReadOnly)
 
you can go through fields collection, something like below:


dim fld as field
i=2

for each fld in rst.fields
cell(1,i)=fld.name
i=i+1
next fld
 
Back
Top