rltomalin
asked on
Grouping form fields together
I have a form where I wish to "expose" certain fields dependant on the value entered in a combo box.
I have the code working fine, but there are several fields for each option and I wondered if there was any way to group fields together (with a name designation) so that the code can sort of say:
If cboBox = "Value" Then
FieldGroup.BackColor = -2147483633
End If
or something like that.
Just thinking about readability of the code and ease of maintenance.
Regards
Richard
I have the code working fine, but there are several fields for each option and I wondered if there was any way to group fields together (with a name designation) so that the code can sort of say:
If cboBox = "Value" Then
FieldGroup.BackColor = -2147483633
End If
or something like that.
Just thinking about readability of the code and ease of maintenance.
Regards
Richard
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Another way to do this with logically grouped controls is to define the group with a consistent naming convention using sequential numbers, and loop through the controls based on name.
For example, name a group of textboxes txtThing01, txtThing02, txtThing03 ... etc, and use code like this:
For example, name a group of textboxes txtThing01, txtThing02, txtThing03 ... etc, and use code like this:
Dim I as integer
For I = 1 to 10
If me.cboBox = "Value" then
Me.Controls("txtThing" & Format(I,"00")).backcolor = -2147483633
else
Me.Controls("txtThing" & Format(I,"00")).backcolor = something else
end if
Next
ASKER
Wow - that was quick. I have two solutions here that I will checkout and select which I would prefer.
Thanks for your excellent (as always) support.
Regards
Richard