D
DawnTreader
hello all
i have a table tblwarranty that is related one to many to tblwarrantyparts.
each part in the subtable has a dollar value. there is also tables that
stores the labour hours and travel hours and the other credits.
tblwarrantylabourhours, tblwarrantytravelhours, tblwarrantyothercredits are
all on the many side of the relationship.
when i query these tables to get a line that shows the total value of the
parts, labour, travel and other credits i get a value that is multiples of
what it should be. for example if the number of part lines was 4 and the
total parts was worth $100, the query would give a result of $400.
additionally the labour, travel and other would also be multiplied.
what causes this?
here is the sql:
SELECT
IIf([tblWarrantyClaim]![WarrantyClaimID]<7000,[tblWarrantyClaim]![ClaimNumber],[tblWarrantyClaim]![WarrantyClaimID])
AS Claim, tblWarrantyClaim.ClaimNumber, tblWarrantyClaim.WarrantyClaimID,
subtblWarrantyStatus.Status, Year([DateofClaim]) AS DOCYear,
Format([DateofClaim],"mmm") AS DOCMonth, tblWarrantyClaim.DateofClaim,
tblWarrantyClaim.DateOfFailure, tblWarrantyClaim.DateOfRepair,
tblWarrantyClaim.DatePreauthorized, tblWarrantyClaim.DatePreauthorizedDone,
tblWarrantyClaim.DateSubmittedForAuthorization,
tblWarrantyClaim.DateApproved, tblWarrantyClaim.DateRejected,
tblWarrantyClaim.DateCreditCreated,
IIf([Status]="Credited",Sum(IIf(IsNull([QTY]*[UnitCreditValue]),0,[QTY]*[UnitCreditValue])),0)
AS PartsValue, Sum(IIf(IsNull([Hours]*[Rate]),0,[Hours]*[Rate])) AS
LabourValue, Sum(IIf(IsNull([THours]*[TRate]),0,[THours]*[TRate])) AS
TravelValue, Sum(IIf(IsNull([Value]),0,[Value])) AS TotalOther,
(Sum(IIf(IsNull([QTY]*[UnitCreditValue]),0,[QTY]*[UnitCreditValue])))+(Sum(IIf(IsNull([Hours]*[Rate]),0,[Hours]*[Rate])))+(Sum(IIf(IsNull([THours]*[TRate]),0,[THours]*[TRate])))+(Sum(IIf(IsNull([Value]),0,[Value])))
AS TotalWarranty, tblWarrantyClaim.CreditNumber, tblServiceReps.ServiceRepID,
tblServiceReps.Name AS ServiceRep
FROM ((tblServiceReps RIGHT JOIN (subtblWarrantyStatus INNER JOIN
((tblWarrantyClaim LEFT JOIN tblWarrantyTravelHours ON
tblWarrantyClaim.WarrantyClaimID = tblWarrantyTravelHours.WarrantyClaimID)
LEFT JOIN tblWarrantyLabourHours ON tblWarrantyClaim.WarrantyClaimID =
tblWarrantyLabourHours.WarrantyClaimID) ON subtblWarrantyStatus.StatusID =
tblWarrantyClaim.StatusID) ON tblServiceReps.ServiceRepID =
tblWarrantyClaim.ServiceRepID) LEFT JOIN tblWarrantyOtherCredits ON
tblWarrantyClaim.WarrantyClaimID = tblWarrantyOtherCredits.WarrantyClaimID)
LEFT JOIN tblWarrantyReplacedParts ON tblWarrantyClaim.WarrantyClaimID =
tblWarrantyReplacedParts.WarrantyClaimID
WHERE (((tblWarrantyClaim.WCDateDeleted) Is Null))
GROUP BY
IIf([tblWarrantyClaim]![WarrantyClaimID]<7000,[tblWarrantyClaim]![ClaimNumber],[tblWarrantyClaim]![WarrantyClaimID]),
tblWarrantyClaim.ClaimNumber, tblWarrantyClaim.WarrantyClaimID,
subtblWarrantyStatus.Status, Year([DateofClaim]),
Format([DateofClaim],"mmm"), tblWarrantyClaim.DateofClaim,
tblWarrantyClaim.DateOfFailure, tblWarrantyClaim.DateOfRepair,
tblWarrantyClaim.DatePreauthorized, tblWarrantyClaim.DatePreauthorizedDone,
tblWarrantyClaim.DateSubmittedForAuthorization,
tblWarrantyClaim.DateApproved, tblWarrantyClaim.DateRejected,
tblWarrantyClaim.DateCreditCreated, tblWarrantyClaim.CreditNumber,
tblServiceReps.ServiceRepID, tblServiceReps.Name, subtblWarrantyStatus.Order
ORDER BY subtblWarrantyStatus.Order;
i have a table tblwarranty that is related one to many to tblwarrantyparts.
each part in the subtable has a dollar value. there is also tables that
stores the labour hours and travel hours and the other credits.
tblwarrantylabourhours, tblwarrantytravelhours, tblwarrantyothercredits are
all on the many side of the relationship.
when i query these tables to get a line that shows the total value of the
parts, labour, travel and other credits i get a value that is multiples of
what it should be. for example if the number of part lines was 4 and the
total parts was worth $100, the query would give a result of $400.
additionally the labour, travel and other would also be multiplied.
what causes this?
here is the sql:
SELECT
IIf([tblWarrantyClaim]![WarrantyClaimID]<7000,[tblWarrantyClaim]![ClaimNumber],[tblWarrantyClaim]![WarrantyClaimID])
AS Claim, tblWarrantyClaim.ClaimNumber, tblWarrantyClaim.WarrantyClaimID,
subtblWarrantyStatus.Status, Year([DateofClaim]) AS DOCYear,
Format([DateofClaim],"mmm") AS DOCMonth, tblWarrantyClaim.DateofClaim,
tblWarrantyClaim.DateOfFailure, tblWarrantyClaim.DateOfRepair,
tblWarrantyClaim.DatePreauthorized, tblWarrantyClaim.DatePreauthorizedDone,
tblWarrantyClaim.DateSubmittedForAuthorization,
tblWarrantyClaim.DateApproved, tblWarrantyClaim.DateRejected,
tblWarrantyClaim.DateCreditCreated,
IIf([Status]="Credited",Sum(IIf(IsNull([QTY]*[UnitCreditValue]),0,[QTY]*[UnitCreditValue])),0)
AS PartsValue, Sum(IIf(IsNull([Hours]*[Rate]),0,[Hours]*[Rate])) AS
LabourValue, Sum(IIf(IsNull([THours]*[TRate]),0,[THours]*[TRate])) AS
TravelValue, Sum(IIf(IsNull([Value]),0,[Value])) AS TotalOther,
(Sum(IIf(IsNull([QTY]*[UnitCreditValue]),0,[QTY]*[UnitCreditValue])))+(Sum(IIf(IsNull([Hours]*[Rate]),0,[Hours]*[Rate])))+(Sum(IIf(IsNull([THours]*[TRate]),0,[THours]*[TRate])))+(Sum(IIf(IsNull([Value]),0,[Value])))
AS TotalWarranty, tblWarrantyClaim.CreditNumber, tblServiceReps.ServiceRepID,
tblServiceReps.Name AS ServiceRep
FROM ((tblServiceReps RIGHT JOIN (subtblWarrantyStatus INNER JOIN
((tblWarrantyClaim LEFT JOIN tblWarrantyTravelHours ON
tblWarrantyClaim.WarrantyClaimID = tblWarrantyTravelHours.WarrantyClaimID)
LEFT JOIN tblWarrantyLabourHours ON tblWarrantyClaim.WarrantyClaimID =
tblWarrantyLabourHours.WarrantyClaimID) ON subtblWarrantyStatus.StatusID =
tblWarrantyClaim.StatusID) ON tblServiceReps.ServiceRepID =
tblWarrantyClaim.ServiceRepID) LEFT JOIN tblWarrantyOtherCredits ON
tblWarrantyClaim.WarrantyClaimID = tblWarrantyOtherCredits.WarrantyClaimID)
LEFT JOIN tblWarrantyReplacedParts ON tblWarrantyClaim.WarrantyClaimID =
tblWarrantyReplacedParts.WarrantyClaimID
WHERE (((tblWarrantyClaim.WCDateDeleted) Is Null))
GROUP BY
IIf([tblWarrantyClaim]![WarrantyClaimID]<7000,[tblWarrantyClaim]![ClaimNumber],[tblWarrantyClaim]![WarrantyClaimID]),
tblWarrantyClaim.ClaimNumber, tblWarrantyClaim.WarrantyClaimID,
subtblWarrantyStatus.Status, Year([DateofClaim]),
Format([DateofClaim],"mmm"), tblWarrantyClaim.DateofClaim,
tblWarrantyClaim.DateOfFailure, tblWarrantyClaim.DateOfRepair,
tblWarrantyClaim.DatePreauthorized, tblWarrantyClaim.DatePreauthorizedDone,
tblWarrantyClaim.DateSubmittedForAuthorization,
tblWarrantyClaim.DateApproved, tblWarrantyClaim.DateRejected,
tblWarrantyClaim.DateCreditCreated, tblWarrantyClaim.CreditNumber,
tblServiceReps.ServiceRepID, tblServiceReps.Name, subtblWarrantyStatus.Order
ORDER BY subtblWarrantyStatus.Order;