Loop through objects in Form and change them options!

mixail

Registered User.
Local time
Today, 20:25
Joined
Apr 25, 2010
Messages
18
Dear all,


My question is how to loop and change settings between objects in a form?

For example:
I want to loop between buttons in a form.
Let say they are three.
So i want when i click on button No.1 the other ones to get status enabled=false.

The same "loop issue" i have with list-boxes, i want when i click on some of them to loop and requery others.

BR,
mixail
 
Last edited:
when you click on a control, it becomes active. so for your button issue, universal code for any of them, might be:
PHP:
dim c as control

for each c in me.controls
   if typeof c is controlbutton then
      if not me.activecontrol = c.name then
        c.enabled = false
      else
         c.enabled = true
      end if
   end if
next c
but then again, if you disable others when clicking one, how r u going to click the disabled ones?
 
Thanks.

I'll enable them after from other control.

Thanks again.

BR,
mixail

...........
After the test i have made some small corrections in code:

Code:
    Dim c As Control

    For Each c In Me.Controls
        If TypeOf c Is CommandButton Then
            If Not Me.ActiveControl.Name = c.Name Then
                c.Enabled = False
            Else
                c.Enabled = True
            End If
        End If
    Next c

...

Like that works sharp.

Thanks again.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom