Is it possible to groups form controls?

  • Thread starter Thread starter markmarko
  • Start date Start date
M

markmarko

Is it possible to make a group of controls on a form, so that, for instance,
a property for all controls in that group can be changed simultaneously? Sure
would be nice!
 
Not for the purpose you'd like it for. But if you use some namingconvention
you could programmaticly change properties. So if you have a group for let's
say address you could start each control with "adr" and then loop through the
controls and perform the action you'd like.

hth
 
The way you "group" controls for this kind of manipulation is to use the
little known Tag Property. Select the control(s) then got to Properties -
Other and enter a value in the Tag Property. Don't get confused if you see a
***SmartTag*** Property! This is something else entirely!

For the purposes of this demo, we'll make the Tag Property

Marked

Enter this in the Tag Property box (without quotation marks.)

Also, for purposes of this demo, we'll change the Enabled Property of the
tagged controls to Enabled = False. You can, of course, use the code to set
any property that the particular control type has.

Then, in an appropriate event, use this code.

Dim ctrl As Control

For Each ctrl In Me.Controls
If ctrl.Tag = "marked" Then
ctrl.Enabled = False
End If
Next

End Sub


Be sure that the controls that are tagged actually have the property you're
trying to change, or you'll get an error! For instance, tagging a label
control and then trying to change the Enabled property will error out,
because labels don't have an Enabled property.

The really nice thing is that you can have multiple levels within a form, i.e.
several different Tags being used to identify different groups of controls to
be manipulated.

Linq

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.com
 
Back
Top