Sorting records by a calculated field.

G

Guest

Hello There,

Can anybody help me? I have a report and I am trying to
sort my records by a calculated field.

I would like to list the records on the report by listing
those records with the highest value first in descending
order.

The field is located in the Client ID Header section of
the report (clients are currently sorted by ID in
ascending order)

How can i get the report to sort the clients by highest
value in the calculated field in descending order instead
of client ID in ascending order?

Can anybody please help

Thanks
Adam
 
M

Marshall Barton

Can anybody help me? I have a report and I am trying to
sort my records by a calculated field.

I would like to list the records on the report by listing
those records with the highest value first in descending
order.

The field is located in the Client ID Header section of
the report (clients are currently sorted by ID in
ascending order)

How can i get the report to sort the clients by highest
value in the calculated field in descending order instead
of client ID in ascending order?


It depends on the calculation. You can use an expression in
the sorting and grouping field/expression columns. E.g.

=Price * Quantity

The expression must refer to fields in the report's reord
source, it can not refer to controls on the report.
 
R

Rusty Shackelford

what about totals?
I want a report say on customers sorted by total orders?
But what I realy want is a report that gives a percentage of errors with
subited paperwork ( I have the report I just cant sort on the percentage)
 
A

Allen Browne

Rusty, it makes sense that Access cannot sort the report by a total that it
has not calculated until it has finished making the report. If you wish to
sort by a total, then you must get the total into the report's RecordSource.

You may be able to use a subquery. However, that approach is often
frustrated after you get the query working, and the report complains about a
"multi-level group by". So the solution probably involved creating another
query that calculates the totals (grouped by whatever), and using that query
as an input "table" in the report's query.
 
M

Marshall Barton

Rusty said:
what about totals?
I want a report say on customers sorted by total orders?

To sort on a calculation that involves multiple records, the
sort value must be a field in the report's record source
query. This is normally done using a Totals (Group By) type
query. I would need to understand the report record source,
how each detail record contributes to the total and where
you want to display the total before I can make specific
suggestions on how to construct the report's new query.

But what I realy want is a report that gives a percentage of errors with
subited paperwork ( I have the report I just cant sort on the percentage)

I don't have any idea how you identify a paperwork error
here. This calulation would probably also be done in the
same query as the above total.
--
Marsh
MVP [MS Access]


 
R

Rob

This may sound dumb, but I use it all the time:
If you have the total you want to sort by in the
query...rename the query to QUERYNAME1. Open a new query
and base it off of QUERYNAME1, bring in all the fields and
sort as you need, then save it as the original query
name.

When you open the report, the 2nd query calls the 1st to
run. It runs, generates the variable field you need, then
the 2nd query grabs that data, sorts it, and then feeds it
to to the report.
 

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

Top