BrianBeck
asked on
Retrieving Access field names - in correct order
Hi Gurus
I'm using what I believe to be a fairly standard method of retrieving Access field names:
DbsConnection.Provider = "Microsoft.Jet.OLEDB.4.0"
strOpenMDb = "Data Source=" & FilePathAndName & ";Jet OLEDB:Database Password=" & Password
DbsConnection.Open strOpenMDb
' Use OpenSchema and get the table names.
Set rs = DbsConnection.OpenSchema(a dSchemaCol umns, Array(Empty, Empty, tDef_Onnet_DSLAMs))
rs.MoveFirst
Do While Not rs.EOF
ThisCol = rs!COLUMN_NAME
rs.MoveNext
Loop
However, the order in which it fetches the columns is different to how the columns are displayed within Access.
What do I need to do in order to fetch the column names in the same order as Access - this is most important.
I'm using what I believe to be a fairly standard method of retrieving Access field names:
DbsConnection.Provider = "Microsoft.Jet.OLEDB.4.0"
strOpenMDb = "Data Source=" & FilePathAndName & ";Jet OLEDB:Database Password=" & Password
DbsConnection.Open strOpenMDb
' Use OpenSchema and get the table names.
Set rs = DbsConnection.OpenSchema(a
rs.MoveFirst
Do While Not rs.EOF
ThisCol = rs!COLUMN_NAME
rs.MoveNext
Loop
However, the order in which it fetches the columns is different to how the columns are displayed within Access.
What do I need to do in order to fetch the column names in the same order as Access - this is most important.
urm, scrub that
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
urm missing closing round bracket on OpenDatabase,
doh!
doh!
ASKER
Thanks rockiroads - on the button!
Dim i As Integer
For i = 0 To rs.Fields.Count - 1
Debug.Print i+1,rs.Fields(i).Name
Next i