List Box results from another list box

Hi, on my form i have a CUSTOMER list box which lists all the customers already in the database. I have another list box that is called SIMILAR TOO. I want the SIMILAR TOO list box to only list items that are associated with the CUSTOMER i have already picked in the form. Currently my SIMILAR TOO list box simply lists all of the item in the database. How can i restrict the list to only show if they are associated with same CUSTOMER?

many thanks Max

Hello,

Your question lacks many details to be able to give an answer specific to the results you want but the attached sample should give you a starting point to proceed.

The sample deals with people in companies and their position. On the single form, The Select Person list box allows selection of an item in the People table. Then, using the button and based upon the selected item, the table control displays the record AND the second list box now contains all People who have the same position in any company. Because of the selection method, the second list box also contains the person in the first list box.

So the second list box is based upon a query which is based upon the selected item of the first list box.

Sample: PeopleSameCriteria.odb

Many thanks, i think this will work for me.

OK, so i played with this for hours now and still no further forward. When looking at how the SelectionCriteria query was made I came across an error which would only let me open the query in SQL view. There is mention of CRITERIA but i am unable to see to what this relates. Any further advice?

This is simply SQL. Because of the construction of the statement, LO doesn’t accommodate this in the IDE view so it must be opened in the SQL view (my preferred method anyway). CRITERIA is just a renaming of the Position field to give it a unique name for comparison purposes.

So, for your situation, you must create an SQL statement based upon your requirements of SIMILAR TOO. This is something you never expressed in your question - what exactly this means.

Hi, yes i tried to keep my original question as brief as possible in the hope some kind soul would point me in the right direction. you of course did this and I fear the information you gave me should have been enough for me to work with but my ageing brain wasnt quit eable to get there. I have managed similar scenarios in MS Access years ago but have to admit I am struggling with LO. Hmm i tried to expand and elaborate on my original question but ran out of characters. I will post again. thanks

@MaaX The question here is " What makes the items in the second list box SIMILAR TOO the items in the first list box?" This is where SQL then comes in (even in Access and most other DB’s).