DSum function

pekajo

Registered User.
Local time
Tomorrow, 06:25
Joined
Jul 25, 2011
Messages
135
Hi,
Can someone help in a DSum function.
The following works
aa = DSum("[IncTotal]", "Income", "[mmyy] = '" & vmth & "' AND [IncCA] = & vt")

But when I want to add another AND statement it does not
aa = DSum("[IncTotal]", "Income", "[mmyy] = '" & vmth & "' AND [IncCA] = & vt" & " AND [Incyy] = vcy")

It's the last AND is giving me an error.
Thanks for any help
Peter
 
Try to follow the previous syntax that worked;
aa = DSum("[IncTotal]", "Income", "[mmyy] = '" & vmth & "' AND [IncCA] = " & vt & " AND [Incyy] = " & vcy )
 
It's the last AND is giving me an error.
textual arguments must be enclosed in quotes
Code:
aa = DSum("IncTotal", "Income", "mmyy = '" & vmth & "' AND IncCA = & vt & " AND Incyy = 'vcy'")
... AND Incyy = 'vcy' ... :)


Hint:
The third argument of the Dsum() function (and similar ones) is constructed according to SQL WHERE rules

Good luck!
 
Last edited:
from the context, it seems all Variables are prefixed with "v".
 
Hi,
Can someone help in a DSum function.
The following works
aa = DSum("[IncTotal]", "Income", "[mmyy] = '" & vmth & "' AND [IncCA] = & vt ")

But when I want to add another AND statement it does not
aa = DSum("[IncTotal]", "Income", "[mmyy] = '" & vmth & "' AND [IncCA] = & vt" & " AND [Incyy] = vcy")

It's the last AND is giving me an error.
Thanks for any help
Peter
I doubt either of the two statements work. The apostrophes are badly placed. Should be:

Code:
aa = DSum("[IncTotal]", "Income", "[mmyy] = '" & vmth & "' AND [IncCA] = " & vt)
and
Code:
aa = DSum("[IncTotal]", "Income", "[mmyy] = '" & vmth & "' AND [IncCA] = " & vt & " AND [Incyy] = " & vcy)
Cheers,
Jiri
 
textual arguments must be enclosed in quotes
Code:
aa = DSum("IncTotal", "Income", "mmyy = '" & vmth & "' AND IncCA = & vt & " AND Incyy = 'vcy'")
... AND Incyy = 'vcy' ... :)


Hint:
The third argument of the Dsum() function (and similar ones) is constructed according to SQL WHERE rules

Good luck!
"vcy" is a variable. If it is a string it should be written as,
Code:
aa = DSum("[IncTotal]", "Income", "[mmyy] = '" & vmth & "' AND [IncCA] = & vt" & " AND [Incyy] = '" & vcy & "'")

Best,
Jiri
 
@ Solo712: I thought that is what I posted in post #2 (I assumed it was a number).

 

Users who are viewing this thread

Back
Top Bottom