Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2002
    Location
    Bay Area
    Posts
    511

    Question Unanswered: How can I remove trace lines from a list box?

    My Access 2000 list box is based on a query. After I run a VBA procedure to search for a target in the list, I see trace lines (dotted lines under rows) in the areas above the found target when I drag the scrollbar upward. They could be in a few consecutive rows or randomly displayed throughout the list if the target is toward the end of the list.

    My code does not select an item in the list box until the target has been found. When I use the scrollbar to scroll away and then back, the lines have disappeared.

    Why do lines in the list box appear? How can I avoid them? I could not find this topic in the MS Knowledgebase.

    Thanks.

  2. #2
    Join Date
    Jan 2003
    Posts
    3
    That happens to me also.

    What I did to solve the problem is Refresh or Requery (I think Requery) the control.

  3. #3
    Join Date
    Jan 2002
    Location
    Bay Area
    Posts
    511
    Don't know why, but this fixes the problem. When searching values in a list box with a For loop, use the For loop only to locate the target then exit the loop. List item selection(s) are done outside the For loop, otherwise trace lines (dotted lines) will appear under rows above the target as you scroll them into view. The unwanted trace lines magically get scrubbed away as you drag the scrollbar so the listed items go out and back into view, but they are not a problem for me now that I have found a solution.

    What I'm doing: A target value can be picked from a range of numbers in a combo box drop down list or entered in the combo box. The combo box UPDATE event activates the search. If a target number typed in is larger than all numbers on the list, then the last panel of the list is displayed. My list box 1st column is numerically sorted in ascending order.

    Here is my working code to locate a listed number greater than or equal to the target, and causing the listed item to appear at the top of the panel (by selecting and unselecting the last list item and then coming back up to the found target, selecting it and leaving it unselected).

    If cboTargets.Text = Null Or cboTargets.Text = "" Then Exit Sub
    j = myList.ListCount
    TargetVal = cboTargets.Text

    For i = 1 To j
    If Me!myList.ItemData(i) >= TargetVal Then Exit For
    Next i

    'removing the following code from inside the For loop avoids trace lines in the list box
    Me!myList.Selected(j-1) = True
    Me!myList.Selected(j-1) = False
    If i < j Then Me.myList.Selected(i) = True
    Me!myList = Null 'now nothing is selected

Posting Permissions

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