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

Containers and Controls?? Please help

Status
Not open for further replies.

joebickley

Programmer
Aug 28, 2001
139
GB
Hi I have a number of controls on a form that i want to loop though either reading or changeing the data. The code below shows what i have managed thus far.

Code:
Dim ctrlContainer As Control
Dim ctrlNumber As Integer

For ctrlNumber = 0 To Me.Controls.Count - 1
    Set ctrlContainer = Me.Controls.Item(ctrlNumber)
    ' can get things like   ctrlContainer.Value
    ' can get things like   ctrlContainer.name
Next

The above allows me to look at every item and i can find out its name and value but i only want to pick up one particular control type eg CheckBoxes.

Is there a way of doing this??

Thanks

Joe
 
Hi Joe!

Use:

If cntlContainer.ControlType = acCheckBox Then
do your stuff
End If

Also, you could use a for each loop:

For Each cntlContainer in Me.Controls
If cntlContainer.ControlType = acCheckBox Then
etc
End If
Next cntlContainer

hth
Jeff Bridgham
bridgham@purdue.edu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top