ARGH! Basic query is confounding me !!

TomH

Registered User.
Local time
Today, 15:26
Joined
Nov 3, 2008
Messages
111
I have an inventory table with fields of item number, description, etc. One field is "BeginningInventory". I also have a table populated with line items of invoice sales, against which I wrote a query that gives me a sum of the number of sales, "SalesQuantity", by item number.

I want to write a query that will allow subtraction of an item's SalesQuantity from its BeginningInventory so that I can keep a current count. However, when not all items are sold in a particular period, those items with no sales don't appear in the original query. I have written the second query so that all items appear, but the SalesQuantity field is blank, and I cannot do the subtraction to get my quantity remaining. That subtraction results in another blank field on that item. So, I guess what I need is a way to write the original query such that all items appear (which I can do) AND if there are no sales, that value defaults to zero... or something like that.

I don't know why I can't figure this out... it should be easy. Thanks for any help!!!
 
Thanks, but that article doesn't address my basic question of how I can subtract the sales volume for a particular item if that item had zero sales, since the query for that item reports back a blank field.
 
Do a Left Join on the Sales transactions so all the Products appear on your query and then All the Sales Transactions. You may need to calculate Zero if there is no Sales Transaction.

Simon
 
Simon: That's my question... how do I calculate zero??
 
Figured it out...

RemainingQuantity: [QuantityonHand]-IIf([sumofquantity] Is Null,0,[sumofquantity])

So, if my [sumofquantity] field (the field that sums the sales) is NULL, this equation enters zero in this new field... otherwise it grabs my original amount. I then subtract the calculated value (either the original amount or the zero that replaced the null).
 

Users who are viewing this thread

Back
Top Bottom