Move selected item to top of listbox

G

Guest

I have a FindInList() function which I pass a listbox, a search value, and a
column number (optional, if missing searches all columns, one row at a time).
The function searches the column(s) of the listbox for the first occurance
of the value that was passed, and selects that row.

However, if the row selected is below the last item currently displayed in
the list, the list will refresh itself and display the newly selected item at
the bottom of the list. I would prefer to have this item at the top of the
list, and know I can do this by first selecting the last item in the list,
then selecting the correct value, but this is a "brute force" method. I'm
hoping someone is aware of a technique that would not be as "forceful".

Thanks
 
M

Michel Walsh

Hi,

If the listbox rowsource is an SQL statement, is it possible to be
looking directly in the table(s) though a DLookup or an SQL statement at
this effect? If the RowSource is a list of constants (check RowSourceType if
you are building a generic tool) , it should be available as a delimited
string through RowSource itself.

Hoping it may help,
Vanderghast, Access MVP
 
G

Guest

Michel,

Maybe I didn't explain the situation very well. Yes, this is a function
that I want to put in my toolbox. For most purposes, the rowsource will be a
sql query or a table, but I already have the code to find the record I am
looking for, and select it. Unfortunately, if the row is below the last
record displayed in the listbox, when I set the new value of the list, it
selects the record, and displays it as the last display row in the list.
What I would like to do is display it as the first display row in the list.

Thanks for your assistance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top