Access Running Totals Query needs additional criteria
Hi,
I have included a screenshot of the query for reference.
I am trying to create a running totals query in access.
I have successfully managed this following guidelines on Technet (I forget the reference) and have come up with this expression:
ActualRunTotal: DSum("OrderValue","TblTenderEnquiryIndex","DatePart('m',[DateOrdered])<=" & [DateOrder] & "")
Unfortunately my report narrows down the data by market sector which the user selects before running the query.
Currently the expression returns a running total of all Orders in the TblTenderEnquiryIndex table. It does not narrow it by market sector.
I have tried this:
ActualRunTotal: DSum("OrderValue","TblTenderEnquiryIndex","DatePart('m',[DateOrdered])<=" & [DateOrder] & "" And [TblMarketSector].[ID]=[Forms]![FormReports]![MarketSector1])
where MarketSector1 is the combo on the reports form containing the market sectors
The query doesnt run though with the error: 'You tried to execute a query that doesnt include the specified expression (above) as part of an aggregarte function'
Have I got the syntax wrong for the second 'Where' clause in the DSUM or is it not possible to dig into a separate table (separate from the named domain in the DSUM expression) to filter the results
As ever any help on this would be greatly appreciated.
Thanks a lot
Edit: Epic fail! Cant believe I posted this in the wrong forum. Please can a generous mod move it to the Queries section. Thanks and apologies
Hi,
I have included a screenshot of the query for reference.
I am trying to create a running totals query in access.
I have successfully managed this following guidelines on Technet (I forget the reference) and have come up with this expression:
ActualRunTotal: DSum("OrderValue","TblTenderEnquiryIndex","DatePart('m',[DateOrdered])<=" & [DateOrder] & "")
Unfortunately my report narrows down the data by market sector which the user selects before running the query.
Currently the expression returns a running total of all Orders in the TblTenderEnquiryIndex table. It does not narrow it by market sector.
I have tried this:
ActualRunTotal: DSum("OrderValue","TblTenderEnquiryIndex","DatePart('m',[DateOrdered])<=" & [DateOrder] & "" And [TblMarketSector].[ID]=[Forms]![FormReports]![MarketSector1])
where MarketSector1 is the combo on the reports form containing the market sectors
The query doesnt run though with the error: 'You tried to execute a query that doesnt include the specified expression (above) as part of an aggregarte function'
Have I got the syntax wrong for the second 'Where' clause in the DSUM or is it not possible to dig into a separate table (separate from the named domain in the DSUM expression) to filter the results
As ever any help on this would be greatly appreciated.
Thanks a lot
Edit: Epic fail! Cant believe I posted this in the wrong forum. Please can a generous mod move it to the Queries section. Thanks and apologies
Attachments
Last edited: