I have a query that sums all of the credit card transaction totals. For example Visa 100.00, Mastercard 200.00 and American Express 190.00. The American express amount should only be 95.00 but it is showing 190.00 (double the amount). I checked the table to make sure that there were only two entries totaling 95.00. The query is pulling the name and credit card type from one table and the dollar amount from another table. They are joined on the credit card number. Basically whenever I have a patient that has to transactions entered the sum query is taking those two transactions and treating it like four.
Here is the code Iam using:
SELECT DISTINCT TblSitePaymentInfo.Location AS Expr1, TblMain.Date, TblSitePaymentInfo.TypeOfCard, Sum(TblMain.Payment) AS SumOfPayment
FROM TblMain INNER JOIN TblSitePaymentInfo ON TblMain.[Acct #] = TblSitePaymentInfo.CreditCardNumber
GROUP BY TblSitePaymentInfo.Location, TblMain.Date, TblSitePaymentInfo.TypeOfCard
HAVING (((TblSitePaymentInfo.Location)=[Forms]![FrmMainPosReport]![CmbLocation]) AND ((TblMain.Date) Between [Forms]![FrmMainPosReport]![TxtStartDate] And [Forms]![FrmMainPosReport]![TxtEndDate]));
Here is the code Iam using:
SELECT DISTINCT TblSitePaymentInfo.Location AS Expr1, TblMain.Date, TblSitePaymentInfo.TypeOfCard, Sum(TblMain.Payment) AS SumOfPayment
FROM TblMain INNER JOIN TblSitePaymentInfo ON TblMain.[Acct #] = TblSitePaymentInfo.CreditCardNumber
GROUP BY TblSitePaymentInfo.Location, TblMain.Date, TblSitePaymentInfo.TypeOfCard
HAVING (((TblSitePaymentInfo.Location)=[Forms]![FrmMainPosReport]![CmbLocation]) AND ((TblMain.Date) Between [Forms]![FrmMainPosReport]![TxtStartDate] And [Forms]![FrmMainPosReport]![TxtEndDate]));