Page 1 of 1

MS Access: ORDER BY a value in a form

Posted: Thu Jul 15, 2004 3:46 am
by CESS.tk
I have a search query that depends on values in a form.
I want the user to be able to choose how to order the results.
On the form, I have a combo box with column names from the table. The query ends in:

Code: Select all

ORDER BY [Forms]![Search records]![Order by];
Where [Forms]![Search records]![Order by] refers to the combo box.
However, everything comes out unsorted, since Access doesn't want to see this paramter as the title of a column. (I've tried with column numbers too: same effect.)
Any way around this?

Re:MS Access: ORDER BY a value in a form

Posted: Thu Jul 15, 2004 8:38 am
by CESS.tk
I'll try to explain this a little better, just the bare essentials of the problem:
I've got a column named "Reference Number"
Now if I end my query in

Code: Select all

ORDER BY [Reference Number];
everything is ok. But when I use

Code: Select all

ORDER BY [Type something here:];
and when prompted type in "Reference Number", it doesn't work.
Any ideas?