Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / March 2008

Tip: Looking for answers? Try searching our database.

Dsum() return a negative

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
TeeSee - 09 Mar 2008 21:37 GMT
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))
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.