DSum in a Query

G

Guest

For months I've been trying to work with Dsum. But, I'm just not getting it.
Pls help !

I have a query named qryAttend1 with 3 fields: ss, Chg, qDate

The original table containing all the info is called Attendance, but I
subqueried the info in order to change the field names so they don't match
the originating Table.

Employee absences drop off after a year and they also can earn time back,
but I need the query to calculate depending on the total absences before the
current absence. So, I tried to use the following expression as the 4th
field in the query. But, I keep getting "compile error, in query expression
'DSum ..."

PTotal:DSum("[Timecharged]","Attendance","[AttnSSNumber]=[ss] and [Date] <
[qdate] and > date()-365")

I've also tried the expression with just the SSnumber and get the same error.

Is the syntax wrong, am I putting it in the wrong place....???

The total sql of the query looks like this:

SELECT qryAttendance.ss, qryAttendance.qdate, qryAttendance.chg,
qryAttendance.LD, qryAttendance.ND,
DSum("[Timecharged]","Attendance","[AttnSSNumber]=[ss] and [Date] < [qdate]
and > date()-365") AS PTotal
FROM qryAttendance
ORDER BY qryAttendance.qdate;
 
T

Tom Lake

Employee absences drop off after a year and they also can earn time back,
but I need the query to calculate depending on the total absences before
the
current absence. So, I tried to use the following expression as the 4th
field in the query. But, I keep getting "compile error, in query
expression
'DSum ..."

PTotal:DSum("[Timecharged]","Attendance","[AttnSSNumber]=[ss] and [Date] <
[qdate] and > date()-365")

I've also tried the expression with just the SSnumber and get the same
error.

Is the syntax wrong, am I putting it in the wrong place....???

Try this:

PTotal:DSum("[Timecharged]","Attendance","[AttnSSNumber]='" & [ss] & "' and
[Date] < #" & [qdate] & "# and [Date] > date()-365")

Tom Lake
 
G

Guest

Thank you Tom, you have saved my sanity for one more day.

Tom Lake said:
Employee absences drop off after a year and they also can earn time back,
but I need the query to calculate depending on the total absences before
the
current absence. So, I tried to use the following expression as the 4th
field in the query. But, I keep getting "compile error, in query
expression
'DSum ..."

PTotal:DSum("[Timecharged]","Attendance","[AttnSSNumber]=[ss] and [Date] <
[qdate] and > date()-365")

I've also tried the expression with just the SSnumber and get the same
error.

Is the syntax wrong, am I putting it in the wrong place....???

Try this:

PTotal:DSum("[Timecharged]","Attendance","[AttnSSNumber]='" & [ss] & "' and
[Date] < #" & [qdate] & "# and [Date] > date()-365")

Tom Lake
 

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

Parameter Query with DSum 1
DSum update query with multiple fields 0
Ungrouping in DSUM 4
DSUM in a query 0
DSum in Query 3
DSUM error# Syntax problem? 4
DSum in Query 1
DSum - running total 2

Top