Could someone please explain why the following Dsum() returns a
negative number. Thanks
Dim intRecCount As Integer
intRecCount = DSum("ynDelete", "tblCDMRvalues", ([ynDelete] = Yes))
ruralguy - 10 Mar 2008 01:43 GMT
Try:
intRecCount = DSum("ynDelete", "tblCDMRvalues", "[ynDelete] = Yes"
AFAIK, all of the Domain functions take strings as arguments.
>Could someone please explain why the following Dsum() returns a
>negative number. Thanks
>
>Dim intRecCount As Integer
> intRecCount = DSum("ynDelete", "tblCDMRvalues", ([ynDelete] = Yes))

Signature
RuralGuy (RG for short) aka Allan Bunch MS Access MVP - acXP WinXP Pro
Please post back to this forum so all may benefit.
Richard Rost - 10 Mar 2008 02:16 GMT
In Access, Yes/No values return a -1 if YES and 0 if NO. All you need to do
is multiply your result by -1 and you're fine.
Richard Rost
richard.rost@amicron.com
www.599cd.com
www.AccessLearningZone.com
> Could someone please explain why the following Dsum() returns a
> negative number. Thanks
>
> Dim intRecCount As Integer
> intRecCount = DSum("ynDelete", "tblCDMRvalues", ([ynDelete] = Yes))
BruceM - 10 Mar 2008 15:07 GMT
You are summing values in the ynDelete field. If that is a Yes/No field, a
Yes value is represented by -1. You are adding all of these values (sort
of).
The reason I say "sort of" is because your syntax is incorrect. As ruralguy
pointed out, the criteria part of the expression needs to be a string, but
he left out a closing parentheses. Try this:
intRecCount = DSum("ynDelete", "tblCDMRvalues", "[ynDelete] = Yes")
If there are three records in which ynDelete is True, the expression will
return -3. If you wrap it in the Abs function you will get 3 as the result:
intRecCount = Abs(DSum("ynDelete", "tblCDMRvalues", "[ynDelete] = Yes"))
However, since it seems you want to count the records, DCount would be a
more efficient way to go about it:
intRecCount = DCount("*", "tblCDMRvalues", "[ynDelete] = Yes")
> Could someone please explain why the following Dsum() returns a
> negative number. Thanks
>
> Dim intRecCount As Integer
> intRecCount = DSum("ynDelete", "tblCDMRvalues", ([ynDelete] = Yes))