How do I sort on a calculated field in a report?

G

Guest

I created a calculated, unbound field in a report that i have to sort on. Can
anyone help me figure out how to?

Thanks.
 
G

Guest

Add the calculated field to the Report RecordSource

Select TableName.* , [Field1]+[Field2] As NewField From TableName

Then in the report Grouping and Sorting add the new field "NewField" and
sort by it.

To sort the report by any field it need to be in the Report RecordSource
 
G

Guest

I'm not sure what you mean by "Select TableName". The calculated field is not
in the table. I added this field in the report to calculate percentage on two
other fields that are in the table.

Thanks,

Ofer Cohen said:
Add the calculated field to the Report RecordSource

Select TableName.* , [Field1]+[Field2] As NewField From TableName

Then in the report Grouping and Sorting add the new field "NewField" and
sort by it.

To sort the report by any field it need to be in the Report RecordSource

--
Good Luck
BS"D


Need Help said:
I created a calculated, unbound field in a report that i have to sort on. Can
anyone help me figure out how to?

Thanks.
 
M

Marshall Barton

Need Help said:
I created a calculated, unbound field in a report that i have to sort on. Can
anyone help me figure out how to?


Put the expression for the calculation in Sorting and
Grouping. Be sure to only refer to fields in the report's
record source table/query and no controls on the report.
 
G

Guest

I know that the calculaed field is not in the form, but the formula in the
calculated field probably consist the field from the table

Something like
=[Field1]+[Field2]

So, to the reprot RcordSource you can add another field

NewField: [Field1]+[Field2]

And then sort by the "NewField"

If you need help, please post the report RecordSource and the Control Source
of the calculated text box
--
Good Luck
BS"D


Need Help said:
I'm not sure what you mean by "Select TableName". The calculated field is not
in the table. I added this field in the report to calculate percentage on two
other fields that are in the table.

Thanks,

Ofer Cohen said:
Add the calculated field to the Report RecordSource

Select TableName.* , [Field1]+[Field2] As NewField From TableName

Then in the report Grouping and Sorting add the new field "NewField" and
sort by it.

To sort the report by any field it need to be in the Report RecordSource

--
Good Luck
BS"D


Need Help said:
I created a calculated, unbound field in a report that i have to sort on. Can
anyone help me figure out how to?

Thanks.
 
G

Guest

'No controls on the report' you mean I can't include another calculated field
in this expression? - Field2/Field3, where Field 3 is another calculation not
included in the table. When I copied the calculation into the Grouping and
Sorting, it gave me an error message. I can't get it work.

I have two fields in the table and two calculated fields in the report.
Field1 and Field2 are entered in the table. [Field3] is a calculation on
[Field1*45]. [Field4] is a calculation on [Field2]/[Field3].

Thanks for your help.
 
G

Guest

'No controls on the report' you mean I can't include another calculated field
in this expression? My calculation is [Field2]/[Field3] where Field2 is in
the table and Field3 is a calculated field in the report. If I copy it into
the Grouping and Sorting, it gives me an error message: "Field3"
 
G

Guest

Marshall,
I eliminated the control on the report and copied the expression into
Grouping and Sorting. It worked.
Thanks for your help.

Need Help said:
'No controls on the report' you mean I can't include another calculated field
in this expression? My calculation is [Field2]/[Field3] where Field2 is in
the table and Field3 is a calculated field in the report. If I copy it into
the Grouping and Sorting, it gives me an error message: "Field3"

Marshall Barton said:
Put the expression for the calculation in Sorting and
Grouping. Be sure to only refer to fields in the report's
record source table/query and no controls on the report.
 
M

Marshall Barton

You got the error because your expression used control names
instead of field names. I guess the expression you need to
use could be:
=Field2 / (Field1 * 45)
which uses only **fields** from the table/query.

You can use the same calculation in the report's record
source query as Ofer suggested. It might be easier to
understand, but it makes no difference to the report.

Part of your confusion is because you are using the word
"field" in an ambiguous way. Fields are columns in a table
or query. Controls are the thingies you have in the
form/report that display the value of a field or expression.
A lot of people use field for either one, but not in a
discussion about both where you need to distinguish between
the two different objects.
--
Marsh
MVP [MS Access]


Need said:
'No controls on the report' you mean I can't include another calculated field
in this expression? - Field2/Field3, where Field 3 is another calculation not
included in the table. When I copied the calculation into the Grouping and
Sorting, it gave me an error message. I can't get it work.

I have two fields in the table and two calculated fields in the report.
Field1 and Field2 are entered in the table. [Field3] is a calculation on
[Field1*45]. [Field4] is a calculation on [Field2]/[Field3].

Marshall Barton said:
Put the expression for the calculation in Sorting and
Grouping. Be sure to only refer to fields in the report's
record source table/query and no controls on 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