Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    Feb 2008
    Location
    United Kingdom
    Posts
    490
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Code mystery (MSACESS 2003)

    I have some code which fills two listboxes One listbox has a filter in to narrow down matches. I am looking for the word "The" but results in listbox two show they, then etc. However the unfiltered listbox fills with more rows than the filtered one, ie more rows of the word "The". First listbox has just two rows appear, one as "The", and the other as "the" Can anyone see why this shoud be happening. Thanks

    If WD.Selection.Find.Found Then
    ' Do While WD.Selection.Find.Found

    WD.Selection.MoveStart Unit:=wdWord, Count:=0
    WD.Selection.MoveEnd Unit:=wdWord, Count:=1

    strWordData = WD.Selection.Range
    strWordData = Trim(strWordData)

    WD.Selection.Collapse wdCollapseEnd

    If strWordData = dt Then
    Me.FoundWord.AddItem strWordData
    End If

    Me.DD.AddItem strWordData

    WD.Selection.Find.Execute

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Code mystery (MSACESS 2003)

    You provide far too little information, but it appears to me that the code does exactly what you tell it to do. You don't check whether an item has already been added to the list, so it may be added more than once.

  3. #3
    4 Star Lounger
    Join Date
    Feb 2008
    Location
    United Kingdom
    Posts
    490
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Code mystery (MSACESS 2003)

    Thanks Hans. I found it. The second lists rowsource was not being cleared, as its set as a value list. So it was accumalating. I changed the code to add the len of the row item in case there was something there that could not be seen, the len value did not appear in the list when the code was run until further down the list, so the problem was identified. Something new to remember. Thanks again, regards

Posting Permissions

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