G
Guest
So I was almost done with this entire databse, and then i discovered a major
flaw. When there are two records with the same date, it throws off the entire
query. Most of the fields, for some reason, increase exponentially. When the
records have different dates, the query looks like:
Date SumofHours
1/1 1
1/2 2
When they have the same, it looks like:
Date SumofHours
1/1 192
1/1 192
etc...i have a much larger query, but i imagine you get the point. Now, if i
change the query fields to "group by" instead of "sum" I get the real values,
but I also get exponentially more rows in the query. So even if there are
only 2 records stored in the form, the query returns something like 98 rows
of records.
Anyway, i'll paste the SQL from the query below, and any help would be much
appreciated!
SELECT [Litter Totals].Date, [Route Totaling].Type, Sum([Parking Lot
Totals].[Parking Hours Totals]) AS [SumOfParking Hours Totals], Sum([Spaces
Totals].[Parking Spaces Total]) AS [SumOfParking Spaces Total], Sum([Leaf
Hours Totals].[Leaf Hours Totals]) AS [SumOfLeaf Hours Totals], Sum([Litter
Totals].[Litter Totals]) AS [SumOfLitter Totals], Sum([Bike Totals_1].[Bike
Paths Totals]) AS [SumOfBike Paths Totals], Sum([Misc Totals].[Misc Hours
Totals]) AS [SumOfMisc Hours Totals], Sum(LeafLoads.LeafLoadTotals) AS
SumOfLeafLoadTotals, Sum([Route Totaling].Sweephours) AS SumOfSweephours,
IIf([Type]="RES",[Sweephours],0) AS [Res Totals],
IIf([Type]="BUS",[Sweephours],0) AS [Bus Totals],
IIf([Type]="IND",[Sweephours],0) AS [Ind Totals],
IIf([Type]="ART",[Sweephours],0) AS [Art Totals], [Route Totaling].Curbmiles,
IIf([Type]="BUS",[Curbmiles],0) AS [Bus Miles],
IIf([Type]="ART",[Curbmiles],0) AS [Art Miles],
IIf([Type]="RES",[Curbmiles],0) AS [Res Miles],
IIf([Type]="IND",[Curbmiles],0) AS [Ind Miles], Sum([LeaveTraining
Totals].NonProdHours) AS SumOfNonProdHours, [LeaveTraining Totals].[Sick
Totals], [LeaveTraining Totals].[Flt Totals], [LeaveTraining Totals].[Vac
Totals], [LeaveTraining Totals].[PB Totals], [LeaveTraining Totals].[Hol
Totals], [LeaveTraining Totals].[7100 Totals], [LeaveTraining Totals].[7200
Totals]
FROM [LeaveTraining Totals] INNER JOIN ([Route Totaling] RIGHT JOIN
(LeafLoads INNER JOIN ([Misc Totals] INNER JOIN ([Leaf Hours Totals] INNER
JOIN ([Bike Totals] AS [Bike Totals_1] INNER JOIN ((([Bike Totals] INNER JOIN
[Litter Totals] ON [Bike Totals].Date = [Litter Totals].Date) INNER JOIN
[Spaces Totals] ON [Litter Totals].Date = [Spaces Totals].Date) INNER JOIN
[Parking Lot Totals] ON [Spaces Totals].Date = [Parking Lot Totals].Date) ON
[Bike Totals_1].Date = [Parking Lot Totals].Date) ON [Leaf Hours Totals].Date
= [Bike Totals_1].Date) ON [Misc Totals].Date = [Leaf Hours Totals].Date) ON
LeafLoads.Date = [Misc Totals].Date) ON [Route Totaling].Date =
LeafLoads.Date) ON [LeaveTraining Totals].Date = LeafLoads.Date
GROUP BY [Litter Totals].Date, [Route Totaling].Type,
IIf([Type]="RES",[Sweephours],0), IIf([Type]="BUS",[Sweephours],0),
IIf([Type]="IND",[Sweephours],0), IIf([Type]="ART",[Sweephours],0), [Route
Totaling].Curbmiles, IIf([Type]="BUS",[Curbmiles],0),
IIf([Type]="ART",[Curbmiles],0), IIf([Type]="RES",[Curbmiles],0),
IIf([Type]="IND",[Curbmiles],0), [LeaveTraining Totals].[Sick Totals],
[LeaveTraining Totals].[Flt Totals], [LeaveTraining Totals].[Vac Totals],
[LeaveTraining Totals].[PB Totals], [LeaveTraining Totals].[Hol Totals],
[LeaveTraining Totals].[7100 Totals], [LeaveTraining Totals].[7200 Totals]
HAVING ((([Litter Totals].Date)>=[forms]![frmReports]![txtDateFrom] And
([Litter Totals].Date)<=[forms]![frmReports]![txtDateTo]));
flaw. When there are two records with the same date, it throws off the entire
query. Most of the fields, for some reason, increase exponentially. When the
records have different dates, the query looks like:
Date SumofHours
1/1 1
1/2 2
When they have the same, it looks like:
Date SumofHours
1/1 192
1/1 192
etc...i have a much larger query, but i imagine you get the point. Now, if i
change the query fields to "group by" instead of "sum" I get the real values,
but I also get exponentially more rows in the query. So even if there are
only 2 records stored in the form, the query returns something like 98 rows
of records.
Anyway, i'll paste the SQL from the query below, and any help would be much
appreciated!
SELECT [Litter Totals].Date, [Route Totaling].Type, Sum([Parking Lot
Totals].[Parking Hours Totals]) AS [SumOfParking Hours Totals], Sum([Spaces
Totals].[Parking Spaces Total]) AS [SumOfParking Spaces Total], Sum([Leaf
Hours Totals].[Leaf Hours Totals]) AS [SumOfLeaf Hours Totals], Sum([Litter
Totals].[Litter Totals]) AS [SumOfLitter Totals], Sum([Bike Totals_1].[Bike
Paths Totals]) AS [SumOfBike Paths Totals], Sum([Misc Totals].[Misc Hours
Totals]) AS [SumOfMisc Hours Totals], Sum(LeafLoads.LeafLoadTotals) AS
SumOfLeafLoadTotals, Sum([Route Totaling].Sweephours) AS SumOfSweephours,
IIf([Type]="RES",[Sweephours],0) AS [Res Totals],
IIf([Type]="BUS",[Sweephours],0) AS [Bus Totals],
IIf([Type]="IND",[Sweephours],0) AS [Ind Totals],
IIf([Type]="ART",[Sweephours],0) AS [Art Totals], [Route Totaling].Curbmiles,
IIf([Type]="BUS",[Curbmiles],0) AS [Bus Miles],
IIf([Type]="ART",[Curbmiles],0) AS [Art Miles],
IIf([Type]="RES",[Curbmiles],0) AS [Res Miles],
IIf([Type]="IND",[Curbmiles],0) AS [Ind Miles], Sum([LeaveTraining
Totals].NonProdHours) AS SumOfNonProdHours, [LeaveTraining Totals].[Sick
Totals], [LeaveTraining Totals].[Flt Totals], [LeaveTraining Totals].[Vac
Totals], [LeaveTraining Totals].[PB Totals], [LeaveTraining Totals].[Hol
Totals], [LeaveTraining Totals].[7100 Totals], [LeaveTraining Totals].[7200
Totals]
FROM [LeaveTraining Totals] INNER JOIN ([Route Totaling] RIGHT JOIN
(LeafLoads INNER JOIN ([Misc Totals] INNER JOIN ([Leaf Hours Totals] INNER
JOIN ([Bike Totals] AS [Bike Totals_1] INNER JOIN ((([Bike Totals] INNER JOIN
[Litter Totals] ON [Bike Totals].Date = [Litter Totals].Date) INNER JOIN
[Spaces Totals] ON [Litter Totals].Date = [Spaces Totals].Date) INNER JOIN
[Parking Lot Totals] ON [Spaces Totals].Date = [Parking Lot Totals].Date) ON
[Bike Totals_1].Date = [Parking Lot Totals].Date) ON [Leaf Hours Totals].Date
= [Bike Totals_1].Date) ON [Misc Totals].Date = [Leaf Hours Totals].Date) ON
LeafLoads.Date = [Misc Totals].Date) ON [Route Totaling].Date =
LeafLoads.Date) ON [LeaveTraining Totals].Date = LeafLoads.Date
GROUP BY [Litter Totals].Date, [Route Totaling].Type,
IIf([Type]="RES",[Sweephours],0), IIf([Type]="BUS",[Sweephours],0),
IIf([Type]="IND",[Sweephours],0), IIf([Type]="ART",[Sweephours],0), [Route
Totaling].Curbmiles, IIf([Type]="BUS",[Curbmiles],0),
IIf([Type]="ART",[Curbmiles],0), IIf([Type]="RES",[Curbmiles],0),
IIf([Type]="IND",[Curbmiles],0), [LeaveTraining Totals].[Sick Totals],
[LeaveTraining Totals].[Flt Totals], [LeaveTraining Totals].[Vac Totals],
[LeaveTraining Totals].[PB Totals], [LeaveTraining Totals].[Hol Totals],
[LeaveTraining Totals].[7100 Totals], [LeaveTraining Totals].[7200 Totals]
HAVING ((([Litter Totals].Date)>=[forms]![frmReports]![txtDateFrom] And
([Litter Totals].Date)<=[forms]![frmReports]![txtDateTo]));