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
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