Anyone know?
Did you try something like this? VB Code: Option Explicit ' ' ? TypeName(ctlall) ' ? ctlall.name Private Sub Form_Load() Dim frm As Form Dim ctlAll As Control For Each frm In Forms For Each ctlAll In frm If TypeOf ctlAll Is ListBox Then ctlAll.Enabled = False End If Next ctlAll Next frm End Sub
Option Explicit ' ' ? TypeName(ctlall) ' ? ctlall.name Private Sub Form_Load() Dim frm As Form Dim ctlAll As Control For Each frm In Forms For Each ctlAll In frm If TypeOf ctlAll Is ListBox Then ctlAll.Enabled = False End If Next ctlAll Next frm End Sub
The following sample may work for you: VB Code: Private Sub Command1_Click() Dim lst As Control, i% For Each lst In Me.Controls If TypeOf lst Is ListBox Then If lst.ListCount > 0 Then For i = 0 To lst.ListCount - 1 'do something Next i End If End If Next lst End Sub
Private Sub Command1_Click() Dim lst As Control, i% For Each lst In Me.Controls If TypeOf lst Is ListBox Then If lst.ListCount > 0 Then For i = 0 To lst.ListCount - 1 'do something Next i End If End If Next lst End Sub
your Problem is seems to be solved so mark it as solved
Forum Rules