Avatar of Sreeni Kambala
Sreeni Kambala
 asked on

Combo box, sort selected items first then non selected items in Multi select combo box... Ms Access

How to sort selected items first then non selected items in Multi select combo box... Ms Access
Microsoft Access

Avatar of undefined
Last Comment
crystal (strive4peace) - Microsoft MVP, Access

8/22/2022 - Mon
crystal (strive4peace) - Microsoft MVP, Access

what field decides if they are selected? What is the RowSource for your combobox?

if, for instance, you have a Yes/No field in your table that is keeping track of what is selected, you can add a column to the Query to sort and not show. True is -1. False is 0.
Sreeni Kambala

ASKER
SELECT tbl_Courseprofile.COURSE_NAME, tbl_Courseprofile.COURSE_ID
FROM tbl_Courseprofile
ORDER BY tbl_Courseprofile.COURSE_ID;

But I would like to sort on multi select items first.check box.
crystal (strive4peace) - Microsoft MVP, Access

Would you post an example?
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
Sreeni Kambala

ASKER
I would like to see selected 4 subjects on top then non selected subjects 2 subjects.see attached file.
subject.jpg
crystal (strive4peace) - Microsoft MVP, Access

by example, I meant an example database. Thanks.

Where do you want to display the selections? If in a report or query, there needs to be a field to save if it is selected.  I sometimes create a temporary YesNo field for processing for occasions like this.
Sreeni Kambala

ASKER
ATTACHED DB,
sample.accdb
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
crystal (strive4peace) - Microsoft MVP, Access

thanks for posting a sample.
What are you going to do with this information? where do you want the sorted list to appear? Just write it to a control on the form and do nothing else? On a Report? If a report, or for remembering, there needs to be a field to store whether or not it is selected.

It appears to me that you perhaps need a TrainerCourses table with foreign keys relating to ID in the Trainer table (that is what should be called TrainerID -- I would call the text field TrainerCode) and COURSE_ID
Sreeni Kambala

ASKER
What are you going to do with this information? -> I use this information in edit mode, If I want to deselect one subject, it is easy to see selected items first.This will help when I have hundreds of records.

where do you want the sorted list to appear? --> Is it possible to sort in same combo box?
If not can you help me the code to populate selected items in below text box in 4 rows.

If I select 5 records, would like to see 5 rows in below text box.
crystal (strive4peace) - Microsoft MVP, Access

> "This will help when I have hundreds of records."


I see you are using a multi-select field but unless you are a programmer, this is a terrible thing to do because you will have to write code to process choices. Most developers don't use multi-select fields either.  While it might seem like a cool quick way to get started, they create a lot of work.  Read what I wrote about creating another table.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
Sreeni Kambala

ASKER
Storing the records in trainer profile table, column name COURSE_NAME.Please verify.
crystal (strive4peace) - Microsoft MVP, Access

you are using a multi-select field -- much better to use a related table.
crystal (strive4peace) - Microsoft MVP, Access

Please re-read my previous comments -- I may have edited them after you read them.  thanks.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
crystal (strive4peace) - Microsoft MVP, Access

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.