DSum with number and text criteria (1 Viewer)

dim

Registered User.
Local time
Today, 09:43
Joined
Jul 20, 2012
Messages
54
Hi,

I have a query named “PSAET” with those fields and values:

Clipboard01.jpg

I need to add a new calculated field named “ETAD” which will accumulate the ETD field and the result should be like this:

Clipboard02.jpg

To do this, I created a new query and if I have only one batch, my formula is working fine:
ETAD: DSum("ETD","PSAET","[ON] <= " & [ON])
In reality, I have more batches so to calculate the ETAD I tried this formula, but doesn’t work:
ETAD: DSum("ETD","PSAET","[ON] <= " & [ON] And "[Batch No] = '" & [Batch No] & "'")
I don’t know what is wrong, so please can you help me?

Thank you!
 

isladogs

MVP / VIP
Local time
Today, 13:43
Joined
Jan 14, 2017
Messages
18,186
Your batch no is confusingly a text field.
Try this

Code:
ETAD: DSum("ETD","PSAET","[ON] <= " & [ON] & " And [Batch No] = '" & [Batch No] & "'")
 

dim

Registered User.
Local time
Today, 09:43
Joined
Jul 20, 2012
Messages
54
Is working!
Thank You very much!
 

Users who are viewing this thread

Top Bottom