ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Access field order using ADO (https://www.excelbanter.com/excel-programming/286489-access-field-order-using-ado.html)

raj

Access field order using ADO
 
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



All times are GMT +1. The time now is 03:19 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com