Offering a sorting choice

L

Linda

I am attempting to make it easy for users to open a query by offering two
choices on sorting, by either Grant or Unit ID. I've created a form to do
this, but I'm not sure of the language I need to make this work. I already
have a parameter query set up that asks for the State, but this OR business
is confusing.

Any help is appreciated!

Linda
 
K

Klatuu

Open your query in design view and add an Order By clause something like this:

ORDER BY IIf([Enter Sort]="Grant",[Grant],[UnitID]);

It will prompt for a sort order and then sort on what the user entered.

My preferred way; however, is to use a combo box on a form with the valid
selections and use that in the query:
ORDER BY Forms!MyFormName!MyComboName;
 
L

Linda

Would I put this clause in the Order By area in the Properties box? If so,
it didn't prompt for the sort order.

Linda

Klatuu said:
Open your query in design view and add an Order By clause something like this:

ORDER BY IIf([Enter Sort]="Grant",[Grant],[UnitID]);

It will prompt for a sort order and then sort on what the user entered.

My preferred way; however, is to use a combo box on a form with the valid
selections and use that in the query:
ORDER BY Forms!MyFormName!MyComboName;
--
Dave Hargis, Microsoft Access MVP


Linda said:
I am attempting to make it easy for users to open a query by offering two
choices on sorting, by either Grant or Unit ID. I've created a form to do
this, but I'm not sure of the language I need to make this work. I already
have a parameter query set up that asks for the State, but this OR business
is confusing.

Any help is appreciated!

Linda
 
K

Klatuu

The best way to do this is open the query in design view, then switch to SQL
view, and add the code to the end of the sql statement.
--
Dave Hargis, Microsoft Access MVP


Linda said:
Would I put this clause in the Order By area in the Properties box? If so,
it didn't prompt for the sort order.

Linda

Klatuu said:
Open your query in design view and add an Order By clause something like this:

ORDER BY IIf([Enter Sort]="Grant",[Grant],[UnitID]);

It will prompt for a sort order and then sort on what the user entered.

My preferred way; however, is to use a combo box on a form with the valid
selections and use that in the query:
ORDER BY Forms!MyFormName!MyComboName;
--
Dave Hargis, Microsoft Access MVP


Linda said:
I am attempting to make it easy for users to open a query by offering two
choices on sorting, by either Grant or Unit ID. I've created a form to do
this, but I'm not sure of the language I need to make this work. I already
have a parameter query set up that asks for the State, but this OR business
is confusing.

Any help is appreciated!

Linda
 
Top