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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Debug.print list of control names on form? 1

Status
Not open for further replies.

utc13

Programmer
Oct 25, 2001
43
US
I have a piece of code (see below) that prints the field names of a designated table to the immediate window. I find it very handy. I would like to be able to do the same thing but instead of listing field names of a table I'd like to be able to list all the control names on a designated form object. I couldn't find anything in my search so I thought I'd ask around. Thanks.



Private Sub PrintTableFieldNames()

Dim db As DAO.Database
Dim td As DAO.TableDef
Dim f As DAO.Field

Set db = CurrentDb
Set td = db.TableDefs("tblExample")

For Each f In td.Fields
Debug.Print f.Name
Next f

End Sub
 
I see someone was faster. You where asking about name, try this:

Dim ctl as control
for each ctl in frmYourForm.Controls
debug.print ctl.name
next ctl

Roy-Vidar
 
Might perhaps be interesting to know print what type of control it is?

Dim ctl as control
for each ctl in frmYourForm.Controls
if typeof ctl is combobox then debug.print "Combobox", ctl.name
if typeof ctl is textbox then debug.print "Textbox", ctl.name
...
next ctl
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top