PDA

View Full Version : Applying a condition to lots of items



davidboutche
08-25-2009, 07:32 AM
I have a form with lots of textboxes. What I'm trying to achieve is this:
When user clicks a check box, it will make a large selection of other items become invisible.

I have used this code to apply it to one item:
Private Sub nophoenixbox_change()
If extrainfoform.nophoenixbox = True Then
homenoBox.Visible = False
Else: homenoBox.Visible = True
End If
End Sub

Is there an easy was to write this or do I have to write it out each time?

I know I can do something similar using the 'with' command but is there anything to do it in reverse, ie:

For thisbox
thatbox
anotherbox .visibile = false

Thanks

macropod
08-25-2009, 08:09 PM
The intent of your question isn't clear to me. Two possible approaches, however are:

Private Sub nophoenixbox_change()
If extrainfoform.nophoenixbox = True Then
homenoBox.Visible = False
homenoBox2.Visible = False
homenoBox3.Visible = False
Else
homenoBox.Visible = True
homenoBox2.Visible = True
homenoBox3.Visible = True
End If
End Sub
and

Private Sub nophoenixbox_change()
Dim BoxShow as Boolean
BoxShow = Not extrainfoform.nophoenixbox.Value
homenoBox.Visible = BoxShow
homenoBox2.Visible = BoxShow
homenoBox3.Visible = BoxShow
End Sub

davidboutche
08-30-2009, 07:14 AM
Thanks for that, I used the first example initially myself in the end. I wanted to apply one condition to lots of objects all in one hit.

What I decided to do in the end was group together on the form all the objects that I wanted to apply a condition to in a frame. I would then apply that condition to the frame.

eg:
personsdescriptionframe.visible = false

Hence it would also hide all the other objects in that frame.

Thanks.
David

fumei
09-01-2009, 09:41 AM
All controls in a frame can be conditional in regrards to the frame itself.
Dim oCtl as Control
If personsdescriptionframe.visible = False Then
For Each oCtl in personsdescriptionframe.Controls
oCtl.Visible = False
Next
End If