I have the following query as the control source for a report:
I have 2 controls on the form:
MinMile=Min([intPrevMileage])
MaxMile=Max([intMileage])
The report has a grouping for the car and the following controls:
Mileage==IIf([txtCarCostType]="Gas",[MaxMile]-[MinMile],"")
CarGal=[MyGallons]
AvgMPG=MPG
AvCostPG=[CostNoBod]/[MyGallons]
CostNoBod=Sum([CurCostAmount])
This all works fine, but I need to have a report total to total all of the above items for the entire fleet. When I try to put a copy of these controls in the report total, I get a bunch of different errors. Div 0, overflow, etc.
Can someone help, please? This is the last thing I need to finish and this project is done!
Thanks!
misscrf
It is never too late to become what you could have been ~ George Eliot
Code:
SELECT tblCar.PKCarID, tblCarNum.intCarNum, tblCarStatus.txtCarStatus, tblCarMake.txtCarMake, tblCarModel.txtCarModel, tblCarCostType.txtCarCostType, tblCarCost.DtCostDate, tblCarCost.intGallons, tblCarCost.CurCostAmount, tblCarCost.intPrevMileage, tblCarCost.intMileage, IIf([txtCarCostType]="Gas",[intGallons],Null) AS MyGallons, tblCarCost.PKCarCostID, tblCarCost.FKCostType,
IIf([tblCarCost]![intGallons]>0,[tblCarCost]![CurCostAmount]/[tblCarCost]![intGallons],Null) AS MyAvgGal,
IIf([tblCarCost]![FKCostType]<>6,Sum([tblCarCost]![CurCostAmount]),0) AS CostNoBod,
IIf([intGallons]=0,0,IIf([txtCarCostType]="Gas",Max([intMileage])-Min([intPrevMileage])/Sum([intGallons]),0)) AS MPG
FROM (tblCarStatus RIGHT JOIN (tblCarNum RIGHT JOIN (tblCarModel RIGHT JOIN (tblCarMake RIGHT JOIN tblCar ON tblCarMake.PKCarMakeID = tblCar.FKCarMake) ON tblCarModel.PKCarModelID = tblCar.FKCarModel) ON tblCarNum.PKCarNumID = tblCar.FKCarNum) ON tblCarStatus.PKCarStatusID = tblCar.FKCarStatus) LEFT JOIN (tblCarCostType RIGHT JOIN tblCarCost ON tblCarCostType.PKCarCostTypeID = tblCarCost.FKCostType) ON tblCar.PKCarID = tblCarCost.FKCar
GROUP BY tblCar.PKCarID, tblCarNum.intCarNum, tblCarStatus.txtCarStatus, tblCarMake.txtCarMake, tblCarModel.txtCarModel, tblCarCostType.txtCarCostType, tblCarCost.DtCostDate, tblCarCost.intGallons, tblCarCost.CurCostAmount, tblCarCost.intPrevMileage, tblCarCost.intMileage, IIf([txtCarCostType]="Gas",[intGallons],Null), tblCarCost.PKCarCostID, tblCarCost.FKCostType, IIf([tblCarCost]![intGallons]>0,[tblCarCost]![CurCostAmount]/[tblCarCost]![intGallons],Null);
I have 2 controls on the form:
MinMile=Min([intPrevMileage])
MaxMile=Max([intMileage])
The report has a grouping for the car and the following controls:
Mileage==IIf([txtCarCostType]="Gas",[MaxMile]-[MinMile],"")
CarGal=[MyGallons]
AvgMPG=MPG
AvCostPG=[CostNoBod]/[MyGallons]
CostNoBod=Sum([CurCostAmount])
This all works fine, but I need to have a report total to total all of the above items for the entire fleet. When I try to put a copy of these controls in the report total, I get a bunch of different errors. Div 0, overflow, etc.
Can someone help, please? This is the last thing I need to finish and this project is done!
Thanks!
misscrf
It is never too late to become what you could have been ~ George Eliot