Question Newbie having problems with searching list box

wlhj

New member
Local time
Today, 08:43
Joined
Jan 2, 2010
Messages
2
I hope I am in the right place. I found this site looking for a solution on google. I am working with Access 2007.

I have an application I'm working on that requires a list box for selection. OK. I can do that. I am working with a customers table and for simplicity we'll say it has an auto number field, last name, first name, and ss # field. I have created a list box, and I can highlight a record and select it for editing.

The problem is that as this database grows, I would like to have a text box where the user can search by last name or ss # and it would go to and highlight the first record matching their criteria in the list box as they typed. They would still use the list box for the record selection, but this would help them find a record in the middle very quickly without scrolling.
I would either use buttons or radio buttons for the selection type (last name or ss #).

I need the record in the list box to have focus as they type. I can't find any examples anywhere for this.

Hope I'm not over my head.
 
Perhaps the discussion and sample DB I posted in this thread will help you?
 
Last edited:
Thanks for the code. I'm trying to do something slightly different but close. I want to use a table and not a query and keep the table values on the form so that the operator can still scroll through them.

I believe I can use the code all the way down to the DoCmd.Requery with some modifications. I should not have to requery a list box using table data with this code. Would that be correct? The focus would also go to where I have typed, but I could still manually move the scroll bar to the focus. This could be done, I assume.

I am probably going to use buttons, say for last name and one for SS #. I could basically just use the same code and if last name was itemData (1) and ss # was itemData(2) and the autonumber which is hidden is ItemData(3)., I would simply assign the first button for searching on last to ItemData(1) and the second button for searching on ss# to ItemData(2). The autonumber(CustomerID) would be used to select the record for processing from the selected item.

I would also need to have a command to blank the search box if I selected an item with the mouse. Correct?

What amazes me is how short the code is. I had pictures of pages of code. Remarkable. I can see you've been at this for a while.

Thanks,

Bill
 

Users who are viewing this thread

Back
Top Bottom