View Full Version : listbox multi-queries


kingsgambit
03-27-2002, 02:00 PM
Part of my database that I am building has a section for contacts, on a search form I have a list box where is attached to a query, the listbox shows Firstname,Lastname,Telno. As there will be over hundred contacts in the database I want to be able to have buttons on the form where the user can chooses letters to search will i.e ABC,DEF this will brake down the list.
Ihave made the queries with Like "a*" and they work. How can I get the results from whatever the user clicks on to appear in the same listbox. i.e Whatever button pressed would be the rowsource

Harry
03-28-2002, 02:40 AM
Create the query with "Like a* OR Like b* etc.. then look at the SQL statement of the query. Copy that and place that in the following code:

Dim MyStr As String
MyStr = "SELECT Firstname,lastname,telno, FROM MyTable WHERE lastname Like 'g*' OR lastname Like 'h*';"
Me.lstBox.RowSource = MyStr
Me.lstBox.Requery

Place this code on the OnClick event of the button.

HTH

kingsgambit
03-28-2002, 09:57 AM
Thanks alot that worked