Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CR 9 - Using Next function in a grouped report 1

Status
Not open for further replies.

JanetStackpole

Programmer
Sep 30, 2005
24
US
I have a report listing fuel transactions grouped by vehicle id . It has the following columns

Vehicle id | fueling date | gallons | cost | odometer | miles between fueling |

I am using {odometer} - Next({odometer})to calculate the miles between fueling. This works very well until the vehicle id changes. It then calculates the difference between vehicle 1's odometer and vehicle 2's odometer.

eg vehicle id | date | gallons | cost | odometer | Miles between
32-101 3/11/06 10 20.00 90,000 200
32-101 3/1/06 10 20.00 89,800 19,800

32-102 3/9/06 10 20.00 70,000


Is there a way to correct this?

Thank you very much [yinyang]
 
Try something like this:

If {VehicleID} <> Next({VehicleID}) then
{odometer} - Next({odometer})
else 0


Bob Suruncle
 
Surely
Code:
If {VehicleID} <> Next({VehicleID}) 
and {date} <> Next({date})
then 
{odometer} - Next({odometer})
else 0

You could also try grouping by Vehicle ID and then date, and doing something with maximum/minimum values.

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top