Shelian,
Ok, here's the problem... The database has been set up on spreadsheet
principles, not on database principles. If it was set up on database
principles, there wouldn't be any such thing as a "Op Bal" field in the
Products table. And there wouldn't be a Units In field and a Units Out
field, there would be a TransactionUnits field and a TransactionType
(in/out) field. Even so, getting a running inventory balance like you
are asking for, as far as I know, will need a subquery, or else a domain
function such as DSum() or DLookup(). In both these cases, if you have
a large number of records (which it sounds like you have), the query
will be noticeably slow. One option would be to export your table to
Excel, do your processing there, and then import back into a temporary
table in Access for use in your report. This is an attractive idea, but
not exactly a trivial undertaking - it will take you a while to get it
running sweetly, so a bit of scream control will be needed.
The other aspect is the concept of "the next entry". I am not sure what
you have in your Inventory Transaction table to identify the order of
transactions. A date and time for each transaction? A sequential
TransactionID number or some such? Whatever, you will have to use this
if you decide to try a subquery in Access. If you do this approach,
here is a starting point... I haven't tested this, and it assumes a
sequential TransactionID, but try putting like this in the Field row of
a blank column in the query design grid:
RunningBal: [Products].[Opp Bal] - (SELECT Sum((Nz([Units
In],0)-Nz([Units Out],0))*[Pcs per Unit]) FROM [Inventory Transaction]
WHERE [TransactionID]<[Inventory Transaction].[TransactionID] And
[Product ID]=[Inventory Transaction].[Product ID])
--
Steve Schapel, Microsoft Access MVP
OK this is what I mean (I hope I can explain it better). In my products
table I have a field called "Op Bal". The "Inventory Transaction" table is
where I enter all the daily "Ins & Outs". I want the query &/or the report
to pull the "Op Bal" from the products table & then add or subtract what I
enter from that "Op Bal". I created the "Subtotal" field for the "Ins" the
"Total" field for the "Outs" & the "Grand Total" for the balance after it
figures if units were brought in or sent out. So in other words, the query
has "Op Bal" (from "Products" table), "Units In", "Units Out", "Pcs per
Unit", "Subtotal", "Total" & "Grand Total". The "Grand Total". Each line
may be different so I made it to do it this way & it would figure it either
adding or subtracting & still come up with the balance. Anyway, then I NEED
it to copy the "Grand Total" to the "Op Bal" for the next product with the
same Product ID number. Let's say for Product ID 23456 the op bal is 12000
we bring in 2 units of 250 pcs. Well then that gets added onto 12000 which
would make it 12500. Then the next entry is a different product ID. Two
entries later we send out 3 units of 250 pcs. Now it would take that away
from the 12500 which of course would be 11,750 left. So this figure should
go in the next entry for product ID 23456 when ever it may be, either the
next line or 2 days later. Please tell me you understand now. I am about to
quit trying to figure it out, I just want to SCREAM!!!