Link to home
Start Free TrialLog in
Avatar of BrianBeck
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(adSchemaColumns, 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.
Avatar of rockiroads
rockiroads
Flag of United States of America image

Does this help any?

    Dim i As Integer
   
    For i = 0 To rs.Fields.Count - 1
        Debug.Print i+1,rs.Fields(i).Name
    Next i


urm, scrub that
ASKER CERTIFIED SOLUTION
Avatar of rockiroads
rockiroads
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
urm missing closing round bracket on OpenDatabase,
doh!
Avatar of BrianBeck
BrianBeck

ASKER

Thanks rockiroads - on the button!