[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 368
  • Last Modified:

Position one value at the top in a combo box

Hello Experts
Wondered if there is an (easy) way to do this.

I have a combo box listing the records in a table.  I would like the listing to be sorted alphabetically EXCEPT for one particular entry to appear at the top.  I don't really want to call it AAAentry.

This is not vital, but I would like to do it if possible.

Is this possible?


2 Solutions
Shaun KlineLead Software EngineerCommented:
If you have the ability to change the table design, an easy way would be to add a number field that "groups" the entries, giving the value that you want at the top a lower number, and then modify the query that loads the combo box to sort by grouping and then by name.

If you do not want to do this by changing the table design, a similar option can be done using the IIF statement in the sort order.
Dale FyeCommented:
I generally use a union query, something like:

SELECT myCombo.Field1
SELECT [Field1], [Field1] as SortOnThis FROM your Table
SELECT "Put this one first", "" FROM tblNumbers
WHERE lngNumber = 0
) as myCombo
ORDER BY myCombo.SortOnThis

I have a table in all of my databases "tblNumbers", which contains a single field (lngNumber) and 10 values (the numbers 0-9) for use in cases like this.
rltomalinAuthor Commented:
Thanks for the prompt feedback.  Not sure which solution I will use yet.

Best regards


Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now