calculate balance

eugz

Registered User.
Local time
Today, 18:22
Joined
Aug 31, 2004
Messages
128
Hi All.
I try to create Inventory DB. I have qRequest quiry that display amount devices that was requested by users and qReceived quiry that display total amount devices which was received. I would like create form to display Balance ([received] - [requested]). How to do that?
Thanks.
 
Assuming that your current queries are built on two queries called qryStockOrdered and qryStockReceived and that they have two fields, qtyRequested and qtyReceived.

In the "Field" part of an empty column in query design view type in:

Balance: qryStockReceived.qtyReceived - qryStockOrdered.qtyRequested

Access will probably throw in some braces "[" and "]" around the text following the colon but don't worry about that.

There is no need to put anything in the Table or Sort fields. The same goes for the Criteria field, unless you want to restrict records to balances =, > or < a certain value.

You will need to join the two tables together so that you can tie the received quantities to the requested quantities. Logic says that the way to do this would be on the order number, but you'll have to use whatever common primary key you have defined. To do this use something along the lines of: WHERE qryStockReceived.orderNumber = qryStockOrdered.orderNumber

If you are likely to receive goods in more than one consignment (which, if you need to determine the balance, seems likely), then you may need to create an intial query that first sums all of the received stock entries against each order number, this is presuming that you will maintain separate records for each received consignment rather than having people add the quantities from new consignments to a previous record (which I would not recommend as you will loose historical information, such as when you received how much; the accounting department might be after your guts if they can't withold payment for failed delivery, or determine the exact quantity to pay for).

Once you have all of the values you need in one query then you can use the formula I have provided above, but changing the tblStock part as required.

HTH

Tim

ps: I think that this should probably have been in the Queries Forum, but hey ho.
 

Users who are viewing this thread

Back
Top Bottom