• Unsuccessful FOR NEXT loop (97)

    Author
    Topic
    #373496

    Unsuccessful FOR NEXT loop
    I

    Viewing 1 reply thread
    Author
    Replies
    • #600609

      I don’t have a good way to test this, so I will make two suggestions in the hope that one of them will work.

      1- Try changing the Dim to:

      Dim ctl As Object
      

      This may fail when you try to reference ctl.tag

      2-

      Try changing the function to this:

      'converts commandBar combo box listindex to a meaningful value...
      Function convertListIndex()
      Dim ctl As CommandBarComboBox
          On Error Resume Next
          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
          On Error GoTo 0
      End Function
      
    • #600649

      Can you use the TypeName function here?
      For each ctl…..
      If TypeName(ctl) = “ComboBox” then….

      • #600658

        Close. This will do it:

        Dim ctl As CommandBarControl

        Then loop through the CommandBar’s controls collection and test the typename like this:

        If TypeName(ctl) = “CommandBarComboBox” Then … etc.

    Viewing 1 reply thread
    Reply To: Unsuccessful FOR NEXT loop (97)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: