SELECT VPO.VendorCode, VPOPayment.PaymentID, PaymentID.AccountingReference, PaymentID.PaymentDate, VPO.VPONumber, VPO.OrderDate, VPOItems.ProductID, VPOItems.TotalCost, Sum(nz(vpopayment.VPOAmountPaid)) AS [Amount Paid]
FROM VPO INNER JOIN (PaymentID RIGHT JOIN (VPOItems LEFT JOIN VPOPayment ON (VPOItems.ProductID=VPOPayment.ProductID) AND (VPOItems.VPONumber=VPOPayment.VPONumber)) ON PaymentID.PaymentID=VPOPayment.PaymentID) ON VPO.VPONumber=VPOItems.VPONumber
GROUP BY VPO.VendorCode, VPOPayment.PaymentID, PaymentID.AccountingReference, PaymentID.PaymentDate, VPO.VPONumber, VPO.OrderDate, VPOItems.ProductID, VPOItems.TotalCost
HAVING
((VPO.VendorCode) Like forms!PaymentSearch1.qvendor1 & "*") AND
((VPOPayment.PaymentID) Like forms!PaymentSearch1.qPaymentID1 & "*") AND
((VPOItems.ProductID) Like forms!PaymentSearch1.qproductID1 & "*") AND
((IsNull(forms!paymentsearch1.qbegdate1 And forms!paymentsearch1.qenddate1) Or PaymentID.PaymentDate Between forms!paymentsearch1.qbegdate1 And forms!paymentsearch1.qenddate1)) AND
((IsNull(forms!paymentsearch1.qbegvpo1 And forms!paymentsearch1.qendvpo1) Or VPO.VPONumber Between forms!paymentsearch1.qbegvpo1 And forms!paymentsearch1.qendvpo1));
Access keeps saying the expression is either typed incorrectly or too complex. It worked fine up until I added the last IsNull statemenet and I've checked it to make sure the statement is chosing the right data.
FROM VPO INNER JOIN (PaymentID RIGHT JOIN (VPOItems LEFT JOIN VPOPayment ON (VPOItems.ProductID=VPOPayment.ProductID) AND (VPOItems.VPONumber=VPOPayment.VPONumber)) ON PaymentID.PaymentID=VPOPayment.PaymentID) ON VPO.VPONumber=VPOItems.VPONumber
GROUP BY VPO.VendorCode, VPOPayment.PaymentID, PaymentID.AccountingReference, PaymentID.PaymentDate, VPO.VPONumber, VPO.OrderDate, VPOItems.ProductID, VPOItems.TotalCost
HAVING
((VPO.VendorCode) Like forms!PaymentSearch1.qvendor1 & "*") AND
((VPOPayment.PaymentID) Like forms!PaymentSearch1.qPaymentID1 & "*") AND
((VPOItems.ProductID) Like forms!PaymentSearch1.qproductID1 & "*") AND
((IsNull(forms!paymentsearch1.qbegdate1 And forms!paymentsearch1.qenddate1) Or PaymentID.PaymentDate Between forms!paymentsearch1.qbegdate1 And forms!paymentsearch1.qenddate1)) AND
((IsNull(forms!paymentsearch1.qbegvpo1 And forms!paymentsearch1.qendvpo1) Or VPO.VPONumber Between forms!paymentsearch1.qbegvpo1 And forms!paymentsearch1.qendvpo1));
Access keeps saying the expression is either typed incorrectly or too complex. It worked fine up until I added the last IsNull statemenet and I've checked it to make sure the statement is chosing the right data.