Get column names from table

thepatrik

New member
Local time
Today, 20:04
Joined
Feb 20, 2007
Messages
6
Hi!
Can I do a select query in order to get all the column names from a certain table in access?
 
You could try going thru the system tables (turn them to visible by going thru Tools=> Options => View => System Objects), note that use of these tables is not supported by M$

Or you can do it thru code: Currentdb.Tabledefs("TableName").Fields(0).Name
this will return the name of the first column in table "TableName", so you have to change the 0 to 1 to get field #2, it is what they call a "zero based array", meaning 0 is 1 and 1 is 2 etc....

I hope this helps...
 
This is one to get the field names

Private Sub Columns()
Dim fld As Field
Dim rst As Recordset

Set rst = CurrentDb.OpenRecordset("table1")


For Each fld In rst.Fields
Debug.Print fld.Name
Next
End Sub
 

Users who are viewing this thread

Back
Top Bottom