DSum function (1 Viewer)

pekajo

Registered User.
Local time
Tomorrow, 06:02
Joined
Jul 25, 2011
Messages
133
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
 

bastanu

AWF VIP
Local time
Today, 13:02
Joined
Apr 13, 2010
Messages
1,402
Try to follow the previous syntax that worked;
aa = DSum("[IncTotal]", "Income", "[mmyy] = '" & vmth & "' AND [IncCA] = " & vt & " AND [Incyy] = " & vcy )
 

Eugene-LS

Registered User.
Local time
Today, 23:02
Joined
Dec 7, 2018
Messages
481
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:

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 04:02
Joined
May 7, 2009
Messages
19,245
from the context, it seems all Variables are prefixed with "v".
 

Solo712

Registered User.
Local time
Today, 16:02
Joined
Oct 19, 2012
Messages
828
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
 

Solo712

Registered User.
Local time
Today, 16:02
Joined
Oct 19, 2012
Messages
828
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
 

bastanu

AWF VIP
Local time
Today, 13:02
Joined
Apr 13, 2010
Messages
1,402
@ Solo712: I thought that is what I posted in post #2 (I assumed it was a number).

 

Users who are viewing this thread

Top Bottom