Share via

DSUM report textbox control source with multiple criteria

Anonymous
2017-09-22T15:02:03+00:00

I cannot get the following DSUM to work.  It failed with the addition of the date criteria.  no error, just null.  can someone tell me what is wrong with my criteria syntax?

=-DSum("[amount_amt]","Sales","[account_id]=145 AND [transaction_date_h]=Year(Now()) and [transaction_date_h]=Month(Now())")

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Duane Hookom 26,825 Reputation points Volunteer Moderator
2017-09-22T15:23:01+00:00

You need to have the same level of granularity on both sides of the "=". Try:

=-DSum("[amount_amt]","Sales","[account_id]=145 AND Year([transaction_date_h])=Year(Now()) and Month([transaction_date_h])=Month(Now())")

I believe you could also use

=-DSum("[amount_amt]","Sales","[account_id]=145 AND Format([transaction_date_h],'YYYYMM')=Format(Date(),'YYYYMM')")

If the record source of the report is "Sales" you should be able to use something like:

=Sum([amount_amt] *([account_id]=145 AND Format([transaction_date_h],"YYYYMM")=Format(Date(),"YYYYMM") ) )

Was this answer helpful?

0 comments No comments

0 additional answers

Sort by: Most helpful