How can I stop items in a combo box automatically sorting into al.

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

Guest

I want to create a combo box with, in order, Detached, Semi-detached,
Bungalow, Flat, Other but the choices KEEP appearing alphabetically. I would
be delighted to hear from someone who knows how the answer.
 
assuming the combo box's RowSource is a query or SQL statement, one solution
would be to add a calculated field, using the Switch() function to number
the choices, as

Switch([MyFieldName] = "Detached", 1, [MyFieldName] = "Semi-detached", 2,
[MyFieldName] = "Bungalow", 3, [MyFieldName] = "Flat", 4, [MyFieldName] =
"Other", 5)

replace MyFieldName with the name of the field that holds the values
"Detached", etc. then sort Ascending on the calculated field.

hth
 
If you want to see records in a particular order, you have to be able to
create an expression based on field values to sort. I would probably add a
field to your lookup table that identifies the order. If you don't want to
do that, you could create a sorting expression in the row source sql like;
SortOrder: Instr("DSBFO", Left([YourField],1)
 
Tina,
Many thanks!
Caroline

tina said:
assuming the combo box's RowSource is a query or SQL statement, one solution
would be to add a calculated field, using the Switch() function to number
the choices, as

Switch([MyFieldName] = "Detached", 1, [MyFieldName] = "Semi-detached", 2,
[MyFieldName] = "Bungalow", 3, [MyFieldName] = "Flat", 4, [MyFieldName] =
"Other", 5)

replace MyFieldName with the name of the field that holds the values
"Detached", etc. then sort Ascending on the calculated field.

hth


CarolineMerryl said:
I want to create a combo box with, in order, Detached, Semi-detached,
Bungalow, Flat, Other but the choices KEEP appearing alphabetically. I would
be delighted to hear from someone who knows how the answer.
 
i hoped somebody would post a better solution than that clunky Switch()
function. thanks Duane! <bows and smiles, accepts 2nd oar gratefully and
finds rowing much easier>


Duane Hookom said:
If you want to see records in a particular order, you have to be able to
create an expression based on field values to sort. I would probably add a
field to your lookup table that identifies the order. If you don't want to
do that, you could create a sorting expression in the row source sql like;
SortOrder: Instr("DSBFO", Left([YourField],1)

--
Duane Hookom
MS Access MVP


I want to create a combo box with, in order, Detached, Semi-detached,
Bungalow, Flat, Other but the choices KEEP appearing alphabetically. I
would
be delighted to hear from someone who knows how the answer.
 
I actually would add a field to the table since the order could be
maintained in data rather than an expression.

Thanx,
Duane Hookom
MS Access MVP


tina said:
i hoped somebody would post a better solution than that clunky Switch()
function. thanks Duane! <bows and smiles, accepts 2nd oar gratefully and
finds rowing much easier>


Duane Hookom said:
If you want to see records in a particular order, you have to be able to
create an expression based on field values to sort. I would probably add
a
field to your lookup table that identifies the order. If you don't want
to
do that, you could create a sorting expression in the row source sql
like;
SortOrder: Instr("DSBFO", Left([YourField],1)

--
Duane Hookom
MS Access MVP


I want to create a combo box with, in order, Detached, Semi-detached,
Bungalow, Flat, Other but the choices KEEP appearing alphabetically. I
would
be delighted to hear from someone who knows how the answer.
 
Back
Top