Full Version: Listbox Search
UtterAccess Forums > Microsoft® Access > Access Forms
I have a listbox with several columns. I'd like to place a textbox on the forms' tab box where the listbox resides that lets me search that listbox by a certain column. I have the query for the listbox already stored, can I reuse it without having to specifiy "select....blah blah blah", which is redundant since it's already code in query1. Is there a way to say "execute query1"?
The short answer is "yes, you can probably do this?" The full answer depends, in part, on what exactly you mean by "search that listbox ".
ach column in a list box is numbered from left to right, starting with 0. NORMALLY, the first column, column 0, is bound to the field, so that you can reference a value in your listbox like this, where you are setting a variable: varMyItem = lstBoxofItems or as varMyItem = lstBoxofItems(0)
That is true because the default column is 0. (If that doesn't make sense, please look in the Access Help file for more on listboxes and columns).
However, if you want to work with a value in a different column, you can do so by refering to that column: varMyItem = lstBoxofItems(4)
That means you want to use the fifth column in the listbox.
That is how you're going to be able to search on that other column.
From there, though, I'm not sure what else to suggest to you because it's not entirely clear how this search would work. Do you want to use this information to move the focus of the form to a particular record? Or is there another task to be accomplished?
I want to be able to goto the particular record in the listbox that equals the value in that particular column. example:I could have 10000 records in the listbox and the value in column 5 is what I want to search on.
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.