Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select Field Names from Table 1

Status
Not open for further replies.

Fattire

Technical User
Nov 30, 2006
127
US
I keep searching but can't find this question ever being asked.

How do I extract the field names, data type, and field description from an Access table via SQL or a Query? I don't see any table column name data in the Msys tables.
 
this function returns the field names seperated by a semicolon.
Code:
Public Function getFieldNames(tableName As String) As String
  Dim rs As DAO.Recordset
  Dim fld As DAO.Field
  Set rs = CurrentDb.OpenRecordset(tableName)
  For Each fld In rs.Fields
    getFieldNames = getFieldNames & fld.Name & ";"
  Next fld
  getFieldNames = Left(getFieldNames, Len(getFieldNames) - 1)
End Function

You can show this in a combo or listbox:
[/code]
Private Sub Form_Load()
With Me.Combo0
.RowSource = getFieldNames("tblPersonnel")
.RowSourceType = "value list"
End With
End Sub
[/code]

or you can use the split function on the results from above to split the results into an array. Then you could populate a table with the results.

This does not help you with a query that shows the field names.
 
wow you are awesome... well done, thank you
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top