On a subform I have a checkbox [ExcludeTest] used to exclude a record. Next to that I have a textbox that counts the records excluded (ie checked) named [numTestsExcluded].
The criteria for the subform is based on a combobox on a mainform [cbo_LeaseNumber]
If I test using a query the SQL reads:
SELECT data_GroupData.LeaseNumber, Sum(data_GroupData.ExcludeTest) AS SumOfExcludeTest
FROM data_GroupData
GROUP BY data_GroupData.LeaseNumber
HAVING (((data_GroupData.LeaseNumber)=[Forms]![frm_TestReview]![cbo_LeaseNumber]) AND ((Sum(data_GroupData.ExcludeTest))=True));
Which works fine
When I try to use Dsum in the text box:
=(-(DSum("[ExcludeTest]","data_GroupData","Forms!frm_TestReview![frm_subfrm_TestDataReview]![ExcludeTest]=true" And "[data_GroupData.LeaseNumber]=" & [Forms]![frm_TestReview]![cbo_LeaseNumber])))
I get a count of all the [ExcludeTest] checkboxes that are checked without it filtering for the LeaseNumber.
Where am I going wrong?
Note: I've added the - sign in order to keep the number positive within the display
The criteria for the subform is based on a combobox on a mainform [cbo_LeaseNumber]
If I test using a query the SQL reads:
SELECT data_GroupData.LeaseNumber, Sum(data_GroupData.ExcludeTest) AS SumOfExcludeTest
FROM data_GroupData
GROUP BY data_GroupData.LeaseNumber
HAVING (((data_GroupData.LeaseNumber)=[Forms]![frm_TestReview]![cbo_LeaseNumber]) AND ((Sum(data_GroupData.ExcludeTest))=True));
Which works fine
When I try to use Dsum in the text box:
=(-(DSum("[ExcludeTest]","data_GroupData","Forms!frm_TestReview![frm_subfrm_TestDataReview]![ExcludeTest]=true" And "[data_GroupData.LeaseNumber]=" & [Forms]![frm_TestReview]![cbo_LeaseNumber])))
I get a count of all the [ExcludeTest] checkboxes that are checked without it filtering for the LeaseNumber.
Where am I going wrong?
Note: I've added the - sign in order to keep the number positive within the display