Sort order of combo box control

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a combo box control on a mainform that has 2 columns: ProjectID and
ProjectName

The bound column is column 1, ProjectID, which has a width of 0" so it is
not visible. It sorts ascending by the bound column, but I would like it to
sort ascending by column 2, ProjectName. That way when users click on the
drop-down arrow, the list is in alphabetical order and it's easier to find
the appropriate project.

How can this be accomplished? Thank you!
 
I am not totally understanding your response. The combo box's RowSource is
currently the table Project. Are you saying I need to create a query with
the 2 fields, sort the ProjectName field ascending, and then change the
RowSource to be that query?

Thanks in advance for expanding on this!
Kevin
 
I have a combo box control on a mainform that has 2 columns: ProjectID and
ProjectName

The bound column is column 1, ProjectID, which has a width of 0" so it is
not visible. It sorts ascending by the bound column, but I would like it to
sort ascending by column 2, ProjectName. That way when users click on the
drop-down arrow, the list is in alphabetical order and it's easier to find
the appropriate project.

How can this be accomplished? Thank you!

Add an Order By to the RowSource SQL.

Select YourTable.ProjectID, ProjectName Form Your Table Order By
ProjectName;
 
Kevin said:
I am not totally understanding your response. The combo box's
RowSource is currently the table Project. Are you saying I need to
create a query with the 2 fields, sort the ProjectName field
ascending, and then change the RowSource to be that query?

It doesn't need to be a saved query that you would see in the db window's
query pane. You can just enter a SQL String directly into the RowSource
property and you can use the query designer to do so.

Click the builder button [...] next to the RowSource property where you
currently have your table name entered. You will be asked if you want to
create a query against the table. Indicate "Yes".

The query builder will come up with your table already in it. Just build
the query you need, close the query designer and indicate "Yes" when asked
to save.

What will be saved is the SQL Statement string from that query, but it will
not create a separate query object in the db window.
 
Back
Top