Unsuccessful FOR NEXT loop (1 Viewer)

arage

Registered User.
Local time
Today, 12:23
Joined
Dec 30, 2000
Messages
537
Unsuccessful FOR NEXT loop
I’d appreciate any help on resolving below which I’ve been trying to clear or get around, unsuccessfully.
I wrote the code to examine command bar combo controls and transform the list index into a value in some other variable. Problem is that my command bar also has a button and the for loop crashes on it’s NEXT CTL statement. The error give is run time error 13 “Type mismatch”

I’ve wrestled trying to tell the loop to avoid anything but a combo box, but am unsuccessful thus far, any help is appreciated. The code below is my original problem function, I’ve gone through some other versions as well trying to get rid of the problem but no good so far.

'converts commandBar combo box listindex to a meaningful value...
Function convertListIndex()
Dim ctl As CommandBarComboBox
For Each ctl In CommandBars("Filter Toolbar").Controls
If ctl.tag = "1" Then
filterYear = yearCombo.Text
End If
'
If ctl.tag = "2" Then
filterType = typeCombo.Text
End If
Next ctl
End Function
 
H

hauffa

Guest
Instead of defining ctl as CommandBarComboBox, define it as a control or an object. Then you can use:

If TypeName(ctl) = "CommandBarComboBox" Then
' do your stuff
End If


Hope this helps,

-hauffa
 

Users who are viewing this thread

Top Bottom