SELECT DISTINCT and SORT BY

LB79

Registered User.
Local time
Today, 03:47
Joined
Oct 26, 2007
Messages
505
Hello,

Im having a problem with SELECT DISTINCT and SORT BY. I want to remove dupliates from a ComboBox, but when I use SELECT DISTINCT it cause problems with the SORT BY.
Is there a fix for this?

Thanks
 
Simple Software Solutions

Change your logic to "Group by" to remove duplicates from the rowsource.

Select Towns From Addresses Group By Towns Order by Towns

Coded for brevity only
 
SELECT DISTINCT [YourTable].[YourField]
FROM [YourTable]
ORDER BY [YourTable].[Your Field on which you want to order by];
 
Thanks for replying.
Do you mean in the query the combobox is tied to? If so, then I already tried that but it didnt work. If not in the query, then where?
Thanks again
 
Hi -

In your query, replace SORT BY with ORDER BY. If that doesn't solve the problem, please post your query SQL.

Bob
 
Thanks all for your help. Im not great with Access so sorry if im a bit vague in my replies...
My row source is
SELECT DISTINCT QRY.Type FROM QRY;
Now i just need it to sort (by another field of the query)
 
SELECT DISTINCT QRY.Type FROM QRY
ORDER BY qry.[Your Field on which you want to order by];
 
Ive tried to put the ORDER BY in but it says there is a conflict with SELECT DISTINCT and ORDER BY.
 
Its because you second field need to be in a query try this
first make a query in which sort by that second field on which you want to order by
then make a second query and get distinct value from that first query and dont add any order by clause
 
Doesnt seem to work it will sort on the selected field only
 

Users who are viewing this thread

Back
Top Bottom