• Loop help (97)

    Author
    Topic
    #376386

    Loop help
    I

    Viewing 2 reply threads
    Author
    Replies
    • #616417

      One suggestion

      Add error handling code to display the err.number, to find out the error number being generated. then modify the error handler so that on that particular error it just does resume next.

      • #616527

        Yes I did add an error handler, it helps resume after a type mismatch error that was occurring in the function.

        errorHandler:
            Select Case err.number
                Case 13
                    Resume Next
            End Select
    • #616432

      Is the If statement failing? If it is, why don’t you set a breakpoint on the If statement and see what the contents of ctl.Text and ctl.Type are?
      This may determine what you will do next.
      Pat cheers

      • #616528

        No, the IF statement was not failing it was the NEXT statement, it could not go onto a control that was disabled on the toolbar. For the past 2 weeks I

    • #616452

      What type did you dim ctl as? I assume it was a CommandBarControl. Your problem is that not every CommandBarControl has a text property, so you can’t test for it until you know what kind of control it is. Something like this will work, and you can test for enabled as well:

        For Each ctl In CommandBars("Filter Toolbar").Controls
           If ctl.Type = msoControlComboBox And ctl.Enabled = True Then
              If Len(Trim(ctl.Text & vbNullString)) > 0 Then
                I = I + 1
              End If
           End If
        Next

      I’m not testing for an empty string because depending on how the combobox is set up, you may have a space or even a null value.

      • #616533

        Thanks for the idea but I got around my problem another way that seems to be working after 3 weeks of struggling. I just hit upon it so I

    Viewing 2 reply threads
    Reply To: Reply #616533 in Loop help (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:




    Cancel