DSum function criteria using between

M

Mark

Hello all,

I need to get a sum between a date range. I am using to varibles on date to
do this, but haven't found the correct syntax yet. What am I doing wrong?
vSDate and vEDate are my varibles.

vSQL = DSum("[qty_picked]", "VIAWARE_AFRM_TO_VIA_T", "[dtimemod] between
vSDate and vEDate")
 
K

Klatuu

It is not the between that is the problem, it is that the variables you are
referencing are inside the quotes. Try this:
vSQL = DSum("[qty_picked]", "VIAWARE_AFRM_TO_VIA_T", & _
"[dtimemod] between " & vSDate & " and " & vEDate & "")
The above syntax is if the variables vSDate and vEDate are date type
varialbes. If they are textbox values, then they have to be considered
strings and delimited with # so they will be seen as dates
vSQL = DSum("[qty_picked]", "VIAWARE_AFRM_TO_VIA_T", & _
"[dtimemod] between #" & vSDate & "# and #" & vEDate & "#")
 
T

Tim Ferguson

vSQL = DSum("[qty_picked]", "VIAWARE_AFRM_TO_VIA_T", & _
"[dtimemod] between #" & vSDate & "# and #" & vEDate & "#")

This is, of course, not safe for the rest of the world that does not use
USAian dates.


Tim F
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top