List of textboxes controls names

F

Felipe Rivera

I want to get a list of the textboxes names in the report
footer section so that I can delete them before I create
new controls in the footer. I have tried the
DeleteReportControl but I need to know the name of the
control to delete it using this method. Since the program
will assign random names to the controls I will not know
the names unles I get a list of the controls. How can I do
this with VBA?
 
M

Marshall Barton

Felipe said:
I want to get a list of the textboxes names in the report
footer section so that I can delete them before I create
new controls in the footer. I have tried the
DeleteReportControl but I need to know the name of the
control to delete it using this method. Since the program
will assign random names to the controls I will not know
the names unles I get a list of the controls. How can I do
this with VBA?

On a Win9x system, you can use:

Dim ctl As Control
For Each ctl In Reports!thereport.Section(2).Controls
If ctl.ControlType = acTextbox Then
Debug.Print ctl.Name
End If
Next ctl

Because of an incompatability, that will not work on a Win
NT or XP system. You'll have to use this more general code:

Dim ctl As Control
For Each ctl In Reports!thereport.Controls
If ctl.Section = 2 Then
If ctl.ControlType = acTextbox Then
Debug.Print ctl.Name
End If
End If
Next ctl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top