looping all combobox in frame2
-
- PlatinumLounger
- Posts: 4368
- Joined: 26 Apr 2010, 17:36
looping all combobox in frame2
i need to loop all combobox in frame2 in a form and get the .tag value... if the .tag value is >=1
-
- Administrator
- Posts: 78586
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: looping all combobox in frame2
Code: Select all
Dim ctl As Control
For Each ctl In Me.Frame2.Controls
If TypeName(ctl) = "ComboBox" And Val(ctl.Tag) >= 1 Then
' Do something with ctl
Debug.Print ctl.Name
End If
Next ctl
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4368
- Joined: 26 Apr 2010, 17:36
Re: looping all combobox in frame2
METHOD OR DATA MEMBER NOT FOUND in bold line For Each ctl In Me.Frame2.ControlsHansV wrote: ↑24 Nov 2021, 15:38Code: Select all
Dim ctl As Control For Each ctl In Me.Frame2.[b]Controls[/b] If TypeName(ctl) = "ComboBox" And Val(ctl.Tag) >= 1 Then ' Do something with ctl Debug.Print ctl.Name End If Next ctl
-
- Administrator
- Posts: 78586
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: looping all combobox in frame2
As you know, I don't have VB6. I tested on a userform in Excel. Does this work?
Code: Select all
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.Container Is Me.Frame2 Then
If TypeName(ctl) = "ComboBox" And Val(ctl.Tag) >= 1 Then
' Do something with ctl
Debug.Print ctl.Name
End If
End If
Next ctl
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4368
- Joined: 26 Apr 2010, 17:36
Re: looping all combobox in frame2
ERROR 438.in If ctl.Container Is Me.Frame2 ThenHansV wrote: ↑24 Nov 2021, 16:40As you know, I don't have VB6. I tested on a userform in Excel. Does this work?
Code: Select all
Dim ctl As Control For Each ctl In Me.Controls If ctl.Container Is Me.Frame2 Then If TypeName(ctl) = "ComboBox" And Val(ctl.Tag) >= 1 Then ' Do something with ctl Debug.Print ctl.Name End If End If Next ctl
-
- Administrator
- Posts: 78586
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
-
- Administrator
- Posts: 78586
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
-
- PlatinumLounger
- Posts: 4368
- Joined: 26 Apr 2010, 17:36
-
- PlatinumLounger
- Posts: 4368
- Joined: 26 Apr 2010, 17:36
-
- Administrator
- Posts: 78586
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: looping all combobox in frame2
Perhaps this?
Code: Select all
Dim ctl As Control
For Each ctl In Me.Controls
If Not ctl.Container Is Nothing Then
If ctl.Container.Name = "Frame2" Then
If TypeName(ctl) = "ComboBox" And Val(ctl.Tag) >= 1 Then
' Do something with ctl
Debug.Print ctl.Name
End If
End If
End If
Next ctl
Best wishes,
Hans
Hans
-
- Administrator
- Posts: 78586
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: looping all combobox in frame2
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4368
- Joined: 26 Apr 2010, 17:36