Calculations on adjacent records

  • Thread starter Thread starter Mike Thurgood
  • Start date Start date
M

Mike Thurgood

I'm trying to determine a way to have a field show up in a
report that shows the difference between the PSE field in
the current record and the PSE field in the prior record
(i.e., <Field in current record> - <Field in prior record>
Is there any way to do this in either the underlying query
or using Detail_Print such that the result is correct even
if the user jumps between pages in print preview?

Thanks!
 
Mike said:
I'm trying to determine a way to have a field show up in a
report that shows the difference between the PSE field in
the current record and the PSE field in the prior record
(i.e., <Field in current record> - <Field in prior record>
Is there any way to do this in either the underlying query
or using Detail_Print such that the result is correct even
if the user jumps between pages in print preview?


You can not do this using code in a report's event
procedures.

You'll have to com up with a query that Joins the data table
to itself in such a way that each record matches up with the
"previous" record. This is only doable if the table (or a
query based on the table) has a field that allows you to use
a simple algorithm to determine the "previous" record based
on the current record.

Either that or use a subquery (or a funtion) to get a
field's value from the "previous" record (this can be slow).

Obviously, the first thing you have to do is figure out how
you can identify the "previous" record. Keep in mind that
relational databse tables do not have an inherant order to
their records, the order must be determined from the data in
each record. Note also that you can not use an AutoNumber
field for this purpose.
 
Back
Top