Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2004
    Location
    Westport, CT
    Posts
    3

    Unanswered: Listbox - How to highlight desired row

    I am opening a form with a listbox (that I populate with a dynamic sql query) and it works fine.

    Now I would like to jump to the row in the listbox that contained the user's search term. It will be in the first column of the listbox.

    I tried the following, but it does not work. Can someone please tell me how to highlight the desired row of a listbox?

    Dim ctl as control, txtSearchTerm as string, itemfound as variant
    Set ctl = Me!mylistbox
    For Each Item in ctl
    if ctl.Column(0, Item) = txtSearchTerm then itemfound = Item
    Next Item
    ctl.Selected(itemfound) = True

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    have you bound the list box to the column containing the search terms?

  3. #3
    Join Date
    Nov 2004
    Location
    Westport, CT
    Posts
    3

    RE: Listbox - How to highlight desired row

    No. Unfortunately, the form I am opening (which contains ths listbox in question) cannot be bound. I really think I need to loop through each of the listbox items to search for my text string. I don't know why my FOR EACH doesn't work with a listbox control in Access...?

Posting Permissions

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