Top value in a drop down box

L

Lydia

Hi,

Is there a way to make a certain value to appear at very top of the
drop-down value list of a drop-down box? It is a text value, say "Base Line",
and I want to it to be the first value in the list, before values such as
"AWD".

Thanks.
 
A

Arvin Meyer MVP

Add a sort column to your table of type Integer or Long. Add that column to
the RowSource of the combobox, with the Order By clause sorting on that
column.

or:

Write a custom function and use that as a RowSource.

or:

Use a Value List
 
K

ken

For the combo box's RowSource property use a UNION ALL query like
this:

SELECT YourField, 0 AS SortColumn
FROM YourTable
WHERE YourField = "Base Line"
UNION ALL
SELECT YourField, 1
FROM YourTable
WHERE YourField <> "Base Line"
ORDER BY SortColumn, YourField;

Ken Sheridan
Stafford, England
 
L

Lydia

After i posted the question, I kind of figured out my own way of doing it and
I would like to share it:

For the combo box row source, I put down:

SELECT myfield FROM my table
ORDER BY IIf([myfield]="Base line","00 base line",[myfield]);

This will work if no one breaks my assumption which is since myfield is a
text field, no one would enter anything that will start with a number let
alone a couple of 0s.

On the safe side, your way may work the best.

Thanks.
--
Lydia Liu
Access/VB Programmer



For the combo box's RowSource property use a UNION ALL query like
this:

SELECT YourField, 0 AS SortColumn
FROM YourTable
WHERE YourField = "Base Line"
UNION ALL
SELECT YourField, 1
FROM YourTable
WHERE YourField <> "Base Line"
ORDER BY SortColumn, YourField;

Ken Sheridan
Stafford, England
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top