Grouping Fields

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Within the coding of the form is there anyway of grouping fields under one
name then preforming actions against that grouped name. For example, could
you group fields called 'Name', 'Address', 'Telephone' under the name
'Personal' then do a visible action (through an IF statement) on the group
called Personal?
 
Pap said:
Within the coding of the form is there anyway of grouping fields under one
name then preforming actions against that grouped name. For example, could
you group fields called 'Name', 'Address', 'Telephone' under the name
'Personal' then do a visible action (through an IF statement) on the group
called Personal?


There is no "group" feature for controls. However, there
are several ways to simulate it.

In many situations, the simplest thing you can do is to set
those control's Tag property to a "group" identifier string
and then can use a loop through all controls to operate on
the ones in the "group".

For example, set The name address and phone text box's Tag
property to Personal. Then the code would be like:

Sub ShowHideGroup(GroupName As String, OnOff As Boolean)
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.Tag = GroupName Then
ctl.Visible = OnOff
End If
Next ctl
End Sub

and call the procedure

ShowHideGroup "Personal", False
 
Back
Top