Dsum syntax

  • Thread starter Thread starter GAllen
  • Start date Start date
G

GAllen

I can't seem to get this Dsum right.

Dim PreviousScore as Integer
Dim rst As DAO.Recordset
Set rst = Form.RecordsetClone
rst.MoveFirst
PreviousScore = DSum("[Score]", "qryScoring", "GID < '" & rst("GID") & "'
And Location = " & rst("Location"))

rst("GID") is Long, rst("Location") is Integer

PreviousScore = DSum("[Score]", "qryScoring", "GID < " & rst("GID"))
returns 6 which is correct.
but when I add the second criteria I get PreviousScore = 0 and it should be
2. I suspect the
Dsum is failing because my quotes placements are incorrect.
Thanks,
GAllen
 
If GID is Long, you don't need the single quotes you've got:

PreviousScore = DSum("[Score]", "qryScoring", "GID < " & rst("GID") & " And
Location = " & rst("Location"))
 
Works great!
Thankyou Douglas

Douglas J. Steele said:
If GID is Long, you don't need the single quotes you've got:

PreviousScore = DSum("[Score]", "qryScoring", "GID < " & rst("GID") & "
And Location = " & rst("Location"))


--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


GAllen said:
I can't seem to get this Dsum right.

Dim PreviousScore as Integer
Dim rst As DAO.Recordset
Set rst = Form.RecordsetClone
rst.MoveFirst
PreviousScore = DSum("[Score]", "qryScoring", "GID < '" & rst("GID") & "'
And Location = " & rst("Location"))

rst("GID") is Long, rst("Location") is Integer

PreviousScore = DSum("[Score]", "qryScoring", "GID < " & rst("GID"))
returns 6 which is correct.
but when I add the second criteria I get PreviousScore = 0 and it should
be 2. I suspect the
Dsum is failing because my quotes placements are incorrect.
Thanks,
GAllen
 

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

Back
Top