Answered by:
Sorting the options within a combo box

Question
-
I have a Table (tbl.Suppliers) and this contains SupplierNo, SupplierName, address and other info not related to this issue. I have created a List box from where i want to select a whole range of different information from different tables. Therefore I have built a query (qry_List) and based my List Box on that query. putting all the other information from the various other tables included in "qry_List" to one side for the moment, and just concentrating on the Suppliers information, I have included the fields "SupplierName" and "SupplierNo" from "tbl_Suppliers". In order to make a selection of the may records that are displayed in the List box, i have added a "Suppliers" Combo Box in order that I might filter out some of the other stuff.
Here is the nub of my problem. I have set the "Suppliers" Combo box to display Supplier Number and supplier Name with the "Bound" column being the supplier number. This works fine. HOEWEVER the original table contains records that are not in order and also there are some entries in the suppliers Table that don't have a supplier number. Sometimes I want to make a selection while only having the Supplier Number and sometimes I need to select while only having the Supplier Name.
I am trying to find a way to have the Combo Box filter out and display only the records that have a Supplier Number in the Field (WEHERE SupplierNumber does not have an entry) and THEN I need to display all of the Supplier Numbers OR the Supplier Names AND have them displayed in EITHER Supplier Number OR Supplier Name ORDER (Ascending or Descending). I am currently trying to do this within the properties of the "Suppliers" Combo Box but I keep hitting problems.
Does this make sense and could anyone help please?
many thanks RayC
Sunday, March 27, 2016 1:11 PM
Answers
-
Hi Ray. If you're taking about changing the contents or sort order of the combo while you're using it, then you'll have to change its RowSource property at runtime. For example,
Me.ComboName.RowSource="Your query SQL here"
Hope that helps...
- Edited by .theDBguy Sunday, March 27, 2016 2:18 PM
- Proposed as answer by Deepak Saradkumar PanchalMicrosoft contingent staff Tuesday, April 5, 2016 9:14 AM
- Marked as answer by Deepak Saradkumar PanchalMicrosoft contingent staff Tuesday, April 5, 2016 9:14 AM
Sunday, March 27, 2016 2:16 PM -
SELECT Supplier_Number, Supplier_Name FROM Suppliers WHERE Supplier_Number = 0 (or NULL) ORDER BY Supplier_Name ASC
Best regards, George
- Proposed as answer by Deepak Saradkumar PanchalMicrosoft contingent staff Tuesday, April 5, 2016 9:14 AM
- Marked as answer by Deepak Saradkumar PanchalMicrosoft contingent staff Tuesday, April 5, 2016 9:14 AM
Monday, March 28, 2016 11:20 AM
All replies
-
Hi Ray. If you're taking about changing the contents or sort order of the combo while you're using it, then you'll have to change its RowSource property at runtime. For example,
Me.ComboName.RowSource="Your query SQL here"
Hope that helps...
- Edited by .theDBguy Sunday, March 27, 2016 2:18 PM
- Proposed as answer by Deepak Saradkumar PanchalMicrosoft contingent staff Tuesday, April 5, 2016 9:14 AM
- Marked as answer by Deepak Saradkumar PanchalMicrosoft contingent staff Tuesday, April 5, 2016 9:14 AM
Sunday, March 27, 2016 2:16 PM -
SELECT Supplier_Number, Supplier_Name FROM Suppliers WHERE Supplier_Number = 0 (or NULL) ORDER BY Supplier_Name ASC
Best regards, George
- Proposed as answer by Deepak Saradkumar PanchalMicrosoft contingent staff Tuesday, April 5, 2016 9:14 AM
- Marked as answer by Deepak Saradkumar PanchalMicrosoft contingent staff Tuesday, April 5, 2016 9:14 AM
Monday, March 28, 2016 11:20 AM -
I hope that this goes back to both George and DB Guy.
My thanks to both of you. Sometimes my head get's so syntax befuddled that I "cant see the wood for the trees". Your kind help to get me pointed back in the right direction is very much appreciated.
Ray C
Monday, March 28, 2016 12:06 PM -
You can mark our contributions as answers if you like ...
Best regards, George
Monday, March 28, 2016 12:36 PM