Two columns in a Query

marksa

Registered User.
Local time
Today, 13:56
Joined
Apr 2, 2002
Messages
13
I have a query that lists names, functions, primary/Alternate/Reference, and contact information.

I have successfully built queries from the main query to break out the specific "functions". I would like to further sort those queries by "P" then "A" then "R". Obviously sorting by ascending or decending doesn't work becauses of the third choice.

Any thoughts.

thanks,
 
Add this calculated field to your query and set sort to Ascending for this new field.

SortOrder: IIf([TableName]![Primary/Alternate/Reference]="P",1,IIf([TableName]![Primary/Alternate/Reference]="A",2,3))


Complete SQL Below:
My Tables name is SortOrder

SELECT SortOrder.Name, SortOrder.Functions, SortOrder.[Primary/Alternate/Reference], SortOrder.Contact, IIf([SortOrder]![Primary/Alternate/Reference]="P",1,IIf([SortOrder]![Primary/Alternate/Reference]="A",2,3)) AS SortOrder
FROM SortOrder
ORDER BY IIf([SortOrder]![Primary/Alternate/Reference]="P",1,IIf([SortOrder]![Primary/Alternate/Reference]="A",2,3));
 

Users who are viewing this thread

Back
Top Bottom