Connecting Tech Pros Worldwide Help | Site Map

Listing fields in a table

JohnM
Guest
 
Posts: n/a
#1: Nov 13 '05
Thanks for the replies regarding adding fields on the fly. .. I'm now
managing that. I can't seem to do something that ought to be more simple,
that is to give the user a list of current fields in a table!


fredg
Guest
 
Posts: n/a
#2: Nov 13 '05

re: Listing fields in a table


On Wed, 26 Oct 2005 06:10:27 +0100, JohnM wrote:
[color=blue]
> Thanks for the replies regarding adding fields on the fly. .. I'm now
> managing that. I can't seem to do something that ought to be more simple,
> that is to give the user a list of current fields in a table![/color]

You can either
1) Set the RowSource type of a combo box to Field List.
Set the RowSource to the name of the table.

or ....

2) Paste the following into a Module

Public Sub GetFieldNames()
Dim dbs As Database, tdf As TableDef, fld As Field
' Return reference to current database.
Set dbs = CurrentDb
For Each tdf In dbs.TableDefs
If Left(tdf.Name, 4) <> "MSYS" Then
Debug.Print tdf.Name
For Each fld In tdf.Fields
Debug.Print " " & fld.Name
Next fld
End If
Next tdf

Set dbs = Nothing
End Sub

--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
Closed Thread