Results 1 to 7 of 7

Thread: Loop help (97)

  1. #1
    4 Star Lounger
    Join Date
    Jun 2001
    Posts
    531
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Loop help (97)

    Loop help
    I

  2. #2
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Loop help (97)

    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.
    Regards
    John



  3. #3
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Loop help (97)

    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 <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Loop help (97)

    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:
    <pre> 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</pre>

    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.
    Charlotte

  5. #5
    4 Star Lounger
    Join Date
    Jun 2001
    Posts
    531
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Loop help (97)

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

    <pre>errorHandler:
    Select Case err.number
    Case 13
    Resume Next
    End Select</pre>


  6. #6
    4 Star Lounger
    Join Date
    Jun 2001
    Posts
    531
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Loop help (97)

    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

  7. #7
    4 Star Lounger
    Join Date
    Jun 2001
    Posts
    531
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Loop help (97)

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •