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

Control Arrays in VBA?

Status
Not open for further replies.

LegionOfDarkness

Technical User
Jul 14, 2003
12
US
Can you create control arrays in VBA so that you can loop through and get results easily?
 
you can Loop through the Controls in a Form..

Control Object, Controls Collection Example

This example is straight out of the ACCESS 97 Help Files

The following example enumerates all the controls in the Controls collection of a form. The procedure is called from a form module and the Me keyword is used to pass the Form object to the procedure. The procedure sets certain properties if the control is a text box.

' Call SetTextBoxProperties procedure.
SetTextBoxProperties Me

Sub SetTextBoxProperties(frm As Form)
Dim ctl As Control

' Enumerate Controls collection.
For Each ctl In frm.Controls
' Check to see if control is text box.
If ctl.ControlType = acTextBox Then
' Set control properties.
With ctl
.SetFocus
.Enabled = True
.Height = 400
.SpecialEffect = 0
End With
End If
Next ctl
End Sub




PaulF


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top