Report will not show identical lines

Rik_StHelens

Registered User.
Local time
Today, 17:01
Joined
Sep 15, 2009
Messages
164
I have a report which calculates the value of the tyre rubber remaining on a vehicle.

The report is based on the following query:

SELECT qryEfficiencyUnbound.[Vehicle Reg], qryEfficiencyUnbound.Tyre, qryEfficiencyUnbound.Pattern, qryEfficiencyUnbound.OTD, qryEfficiencyUnbound.RTD, qryEfficiencyUnbound.Cost, qryEfficiencyUnbound.[Price Per Mil], Sum([tblTyres].[cost])/Sum([otd])*Sum([rtd]) AS [Remaining Value]
FROM tblTyres INNER JOIN qryEfficiencyUnbound ON tblTyres.Pattern = qryEfficiencyUnbound.Pattern
GROUP BY qryEfficiencyUnbound.[Vehicle Reg], qryEfficiencyUnbound.Tyre, qryEfficiencyUnbound.Pattern, qryEfficiencyUnbound.OTD, qryEfficiencyUnbound.RTD, qryEfficiencyUnbound.Cost, qryEfficiencyUnbound.[Price Per Mil];


When I added the Sum([tblTyres].[cost])/Sum([otd])*Sum([rtd]) AS [Remaining Value] line to the SQL, this caused the report to stop displaying identical lines of data.

For example, two tyres fitted at the same time that are the same make/size/pattern/cost have worn equally over time, giving them the same [remaining value]. The report will only display one of the tyres, which then throws out my calculation across the whole vehicle/fleet/depot etc.

Any ideas whats happening here?

Thanks for your time!
 
Your query involves two tables, so when you're referencing a field the table name must precede it with a dot just like you did with [tblTyres].[cost]. Ensure all your fields are prefixed with their table names.
 
Your query involves two tables, so when you're referencing a field the table name must precede it with a dot just like you did with [tblTyres].[cost]. Ensure all your fields are prefixed with their table names.

Have now changed the SQL as you advised so that it now looks like the following:

SELECT qryEfficiencyUnbound.[Vehicle Reg], qryEfficiencyUnbound.Tyre, qryEfficiencyUnbound.Pattern, qryEfficiencyUnbound.OTD, qryEfficiencyUnbound.RTD, qryEfficiencyUnbound.Cost, qryEfficiencyUnbound.[Price Per Mil], Sum([tblTyres].[cost])/Sum(qryEfficiencyUnbound.[otd])*Sum(qryEfficiencyUnbound.[rtd]) AS [Remaining Value]
FROM tblTyres INNER JOIN qryEfficiencyUnbound ON tblTyres.Pattern = qryEfficiencyUnbound.Pattern
GROUP BY qryEfficiencyUnbound.[Vehicle Reg], qryEfficiencyUnbound.Tyre, qryEfficiencyUnbound.Pattern, qryEfficiencyUnbound.OTD, qryEfficiencyUnbound.RTD, qryEfficiencyUnbound.Cost, qryEfficiencyUnbound.[Price Per Mil];

However, I am still getting them same problem in the report, where it does not display identical lines of information.
 
The identical lines are being "Grouped" and "Summed" in your query as per what you are telling it to do: Sum and Group by....
 

Users who are viewing this thread

Back
Top Bottom