C
ChoonBoy
I have a report with its record source set to the following.
SELECT IIf([period]="group","All months",[mthnos]) AS MthNos1,
qPartnerExpGrp.ExpYear, qPartnerExpGrp.PartnerName1,
qPartnerExpGrp.PExpenseID AS ExpenseID, Sum(qPartnerExpGrp.ExpenseReceive) AS
ExpenseReceive, Sum(qPartnerExpGrp.ExpenseCost) AS ExpenseCost,
IIf([period]="group","All months",[expmth]) AS ExpMth1,
qPartnerCount2.CountPnr, qShipmentProfitforPartner.SumOfProfit,
IIf([partner]="company",[sumofprofit],[sumofprofit]/[countpnr]) AS ProfitShr
FROM Tbl_Choice, qPartnerCount2, qPartnerExpGrp INNER JOIN
qShipmentProfitforPartner ON (qPartnerExpGrp.ExpYear =
qShipmentProfitforPartner.ShipYear) AND (qPartnerExpGrp.ExpMth =
qShipmentProfitforPartner.ShipMth) GROUP BY IIf([period]="group","All
months",[mthnos]), qPartnerExpGrp.ExpYear, qPartnerExpGrp.PartnerName1,
qPartnerExpGrp.PExpenseID, IIf([period]="group","All months",[expmth]),
qPartnerCount2.CountPnr, qShipmentProfitforPartner.SumOfProfit,
IIf([partner]="company",[sumofprofit],[sumofprofit]/[countpnr]);
My qPartnerCount2 is actually derived from first grouping a field in a
transaction table and saved as qPartnerCount1 and qPartnerCount2 is used to
give the exact count.
I know this is not the correct way to do this as it give rise to too many
queries in my Query window.
Appreciate help on this with the complete codes.
Thanks
SELECT IIf([period]="group","All months",[mthnos]) AS MthNos1,
qPartnerExpGrp.ExpYear, qPartnerExpGrp.PartnerName1,
qPartnerExpGrp.PExpenseID AS ExpenseID, Sum(qPartnerExpGrp.ExpenseReceive) AS
ExpenseReceive, Sum(qPartnerExpGrp.ExpenseCost) AS ExpenseCost,
IIf([period]="group","All months",[expmth]) AS ExpMth1,
qPartnerCount2.CountPnr, qShipmentProfitforPartner.SumOfProfit,
IIf([partner]="company",[sumofprofit],[sumofprofit]/[countpnr]) AS ProfitShr
FROM Tbl_Choice, qPartnerCount2, qPartnerExpGrp INNER JOIN
qShipmentProfitforPartner ON (qPartnerExpGrp.ExpYear =
qShipmentProfitforPartner.ShipYear) AND (qPartnerExpGrp.ExpMth =
qShipmentProfitforPartner.ShipMth) GROUP BY IIf([period]="group","All
months",[mthnos]), qPartnerExpGrp.ExpYear, qPartnerExpGrp.PartnerName1,
qPartnerExpGrp.PExpenseID, IIf([period]="group","All months",[expmth]),
qPartnerCount2.CountPnr, qShipmentProfitforPartner.SumOfProfit,
IIf([partner]="company",[sumofprofit],[sumofprofit]/[countpnr]);
My qPartnerCount2 is actually derived from first grouping a field in a
transaction table and saved as qPartnerCount1 and qPartnerCount2 is used to
give the exact count.
I know this is not the correct way to do this as it give rise to too many
queries in my Query window.
Appreciate help on this with the complete codes.
Thanks