Access field order using ADO

R

Raj

Please help if possible.

I need to retrieve the field names in an Access database
using ADO, BUT, I need them in the order in which they
appear in the database from left to right.

It seems that the code I'm using alphabetizes them. Your
example code would be MOST appreciated. Thanks in advance.

My code follows:

Function ADOAccessFieldList(argFullName As String,
argTableName As String)

Dim cat As New ADOX.Catalog
Dim tbl As ADOX.Table
Dim fld As ADOX.Column
Dim flds As ADOX.Columns
Dim arrFields() As Variant
Dim lngX As Long

cat.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;"
& "Data Source=" & argFullName & ";"
Set tbl = cat.Tables(argTableName)
Set flds = tbl.Columns
For Each fld In flds
lngX = lngX + 1
ReDim Preserve arrFields(lngX)
arrFields(lngX) = fld.Name
Next fld
ADOAccessFieldList = arrFields

End Function
 
K

KJTFS

Just off the top of my head I would say to

for i = 0 to rs.fields.count -1
rs.fields(i).name
next i


where rs is your recordset.

That will give the names in a left to right order.

Keith
www.kjtfs.com
 

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