Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting control properties

Status
Not open for further replies.

tg2003

IS-IT--Management
Feb 6, 2003
270
IL
Hello,

I'm looking for a way to retrieve all comboboxes in a form and filtering the visibled only.

I'm using a control "for-each" loop. "TypeOf" statement is working, but I can't find how to filter the visible. Is is possible?

Attached is my code.
Thanks

Code:
Dim ctrl As Control
    
    For Each ctrl In Me.Controls
       If TypeOf ctrl Is ComboBox And ctrl.Visible = True Then
            MsgBox (ctrl.text)
       End If
   Next ctrl
 
I forgot to emphasize that

Code:
ctrl.Visible

does not working, and I'm looking for a way to use it.
 
Have u written ur code in an event when the combo boxes are not visible. e.g. Form_Load event.

If so try putting it somewhere else e.g. FOrm_Activate
 
I found the reason.

I must split out the "if" condition, and I understand why. It has to be like this:

Code:
Dim ctrl As Control
    
    For Each ctrl In Me.Controls
       If TypeOf ctrl Is ComboBox Then
            Ifc trl.Visible = True Then
                 MsgBox (ctrl.text)
            End If
       End If
   Next ctrl

Thank you anyway!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top