List of controls

  • Thread starter Thread starter BruceM
  • Start date Start date
B

BruceM

I have spent a fruitless half hour or so trying to find an answer to the
question of how to print a list of controls. I have found several answers
with code something like the following:

Public Sub ListControls()

Dim ctl As Control

For Each ctl In Me.Controls
Debug.Print ctl.Name
Next

End Sub

but I don't know what to do with the code. I have even tried adding a
command button to the form just for the purpose of running the code, but no
luck. I can click the command button, but the code doesn't seem to actually
do anything. Perhaps Print has a different meaning in the world of VBA. My
objective is to come up with a printed list of controls.
 
BruceM wrote in message said:
I have spent a fruitless half hour or so trying to find an answer to the
question of how to print a list of controls. I have found several answers
with code something like the following:

Public Sub ListControls()

Dim ctl As Control

For Each ctl In Me.Controls
Debug.Print ctl.Name
Next

End Sub

but I don't know what to do with the code. I have even tried adding a
command button to the form just for the purpose of running the code, but no
luck. I can click the command button, but the code doesn't seem to actually
do anything. Perhaps Print has a different meaning in the world of VBA. My
objective is to come up with a printed list of controls.

You must enter the immediate pane to study the result. After running
the
code, hit ctrl+g

The easyest path, is to just copy it, paste into something else
(notepad?)
then print.
 
The ability to "print" a list of controls is built into ms-access.

Go

tools->Analyze->Documenter

select the "forms" tab, and then select the form( you can select more then
one).

MAKE SURE you click on the "options" button, and deselect everything but

include for section

x - names

Now, simply hit the "ok" button, you will have a nice printout of your
controls.

As for that code example, it sends the output to the debug window (hit
ctrl-g after you run the code - in the command prompt window...you will your
output if you are into using command prompt stuff).

Also,...try playing with some of the other "options"...as you can have
ms-access show properties...and other stuff about the controls...

The "documentor" can produce printouts of code, sql query...and just about
anything in ms-access.....

Play with it....have fun....
 
Thanks to both for your help. The Analyze > Documenter choice is by far the
simplest. In fact, for me it is still the only choice, since I still can't
figure out how to "run" the code from the code window. It isn't by clicking
Run, apparently. Dealing with code efficiently is an area where my
self-taught understanding has the largest gaps.
 
Back
Top