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 / Queries / July 2006

Tip: Looking for answers? Try searching our database.

Summation fails if Nz used

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Access Greenhorn - 24 Jul 2006 16:55 GMT
If the Nz function is not used in the code below the summation of the field
QtySent is succesful.  If the Nz function is applied to the QtySent field the
summation is still successful.  But as soon as you apply Nz to the
LossedorTossed field the summation fails.  Instead there is a row for each
QtySent entry and the batchcode (PK) and QtyMade and LossedorTossed field
entries are repeated. For example, 5 of item aa were made, 3 were sent out in
one package, 1 was sent out in another package, so the math/ row of data
should be aa, 5-4=11 but instead I get aa, 5-3=2 and aa, 5-1=4.

Sure, I can solve this by defaulting my LossedorTossed field to zero and
only use the Nz function on QtySent but I would like to know why this code is
failing.  

By the way when I write out Nz([field],0) I get the message " You tried to
execute a query that does not include the specified expression
'tblProd1A.QtyMade-nz([QtySent],0)-nz([LossedorTossed],0)' as part of an
aggregate function."

Any idea?

Thanks,
Access Greenhorn

SELECT tblInventoryA.Batchcode, tblProd1A.QtyMade, Sum(tblKitsSent.QtySent)
AS SumOfQtySent, tblInventoryA.LossedorTossed,
[QtyMade]-nz([QtySent])-nz([LossedorTossed]) AS OnHand
FROM tblProd1A LEFT JOIN (tblInventoryA LEFT JOIN tblKitsSent ON
tblInventoryA.Batchcode=tblKitsSent.Batchcode) ON
tblProd1A.Batchcode=tblInventoryA.Batchcode
GROUP BY tblInventoryA.Batchcode, tblProd1A.QtyMade,
tblInventoryA.LossedorTossed, [QtyMade]-nz([QtySent])-nz([LossedorTossed]);
Jeff L - 24 Jul 2006 21:59 GMT
A query with a Group By groups outputted rows that are exactly the
same.  You said that you are getting two rows, so there must be
something about those rows that are different.  You may need to
accomplish your task using more than 1 query.
Access Greenhorn - 24 Jul 2006 22:15 GMT
There is something diff, 3 of item aa were sent in package 1, 1 of item aa
was sent in package 2.  That is why this field is being summed to begin with.

Keep in mind, the group by summation works if the Nz function is not used or
if the Nz function is used with the QtySent field (the field that is being
summed).  It fails when the Nz function is applied to the LossedorTossed
category.
 
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



©2008 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.