Set a secondary sort

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

Guest

How do I set a secondary sort. For example, I want my primary sort to be
last name and the secondary sort to be first name. Can this be done in
Access? If so, how?
 
In query design, you see a Sorting row in the grid.

Choose Ascending under the last [name field], and then ascending under the
[first name] field. The primary sort is the one on the left.
 
Patty Stoddard said:
How do I set a secondary sort. For example, I want my primary sort
to be last name and the secondary sort to be first name. Can this be
done in Access? If so, how?

That depends on what it is that you want sorted. In a query, you can
set multiple sort fields either in the query design grid or by setting
the SQL to include multiple fields in the ORDER BY clause, as for
example:

SELECT * FROM Table1
ORDER BY LastName, FirstName;

On a form, you can sort on multiple fields my using the Records ->
Filter -> Advanced Filter/Sort... function, or by modifying the form's
Order By property on the Data tab of its property sheet.

When viewing a datasheet, you can use the Records -> Filter -> Advanced
Filter/Sort... function I mentioned above.

In a report, the Sorting and Grouping dialog controls the sort order.

If you want to establish a permanent sort order for a form, you'd do
best to base the form on a query that specifies the order you want.
 
Patty Stoddard said:
I used the advanced filter option from the table. What does the icon
load from query do?

I haven't ever really used it, but I gather it allows you to choose some
existing stored query that is based on the same recordsource table as
the form, and use that stored query as the basis of the new filter
(including sort order) for the form.
 
I followed the advice given here and in the help menu. I, too, am trying to
sort by surname and then by forename.

But they are stuck in the wrong order for people with the same surname!
For example Anderson, Rory comes before Anderson, Kirsty.

How can I sort this problem?

Any help much appreciated.
 
Are the stored in same column as shown in your example. If so first you
need to parse them into two fields or three if middle initial/name is also
stored. You can always put them back together easily. If you can work that
change and all have comma's between the names there is a solution here.
http://www.mvps.org/access/strings/str0003.htm
 
Aah, no they are actually in separate columns, I shouldn't have written them
as above!

The two I wish to sort by are Surname and then Forename.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top