Ref a Group of Controls

A

Abdul

How i can refer a group of controls?

for eg. in mu userform when clicking a button i have to hide a few
labels, textboxes and comboboxes.

instead of saying textbox1 visible =false and combobox1 visible =false
etc to refere each control is there a way I can group them and refer
them in a single line?

thanks
 
Z

Zone

Put a distinctive set of characters in the names of the controls you
want to make not visible, such as zz, so rename textbox1 textboxzz1,
for instance, and so on. Then you can refer to them like this:

Dim ctrl As Control
For Each ctrl In Controls
If InStr(ctrl.Name, "zz") > 0 Then ctrl.Visible = False
Next ctrl

James
 
P

Peter T

Another way might be to put the related controls in a Frame

Me.Frame1.Visible = bVis

You could disguise the frame by removing its caption and setting its border
colour to same as the form.

Regards,
Peter T
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top