OR TELL ME THIS: CAN I SUM RECORDS IN TABLEb (when I make temporary table)- BUT NOT ALL THE RECORDS - JUST RECORDS WITH "FIELDX" that is equall to "FIELDX" from TABLEA" (invoice details)???
A summation query can have criteria just like an ordinary SELECT query. In the drop-down that selects Total or Average or Max, there is a Where option so you can limit what you look at. And an Update query could be written based on such a summation query as its data source.
As a side note, INFOS, when you describe a problem and oversimplify it as you did, you invite confusion in those trying to help. I'm not upset with you because you have a difficult problem in spot pricing. Difficult problems, by their very nature, ARE harder to explain. But in the future, you'll get somewhere faster by not totally oversimplifying things quite so much.
I'm going to diverge from the Access issue to give you a different approach. It is not easy. It is not a short answer. But it is absolutely mandatory as a part of the solution to your problem.
Find a dry-erase board, some suitable markers for it, and some sticky-note pads. At least a box worth, not just a pad or two. Draw out the significant parts of your table structure as separate tables. "Populate" the tables by writing "data" on the sticky pads. (I suggest it this way because all these items can be used again later in your business - even the leftover sticky note pads.)
Now, BY HAND, walk through the process of finding the spot price you need to charge. Follow the info in the tables that leads to the data you need in order to compute that price. The issue, as always when doing anything complex, is the "Old programmer's rule:" If you cannot do it on paper, you will NEVER EVER get it right in Access.
Doing it this way will let you SEE the relationships of your database to your actual inventory. Without that visualization, you will get precisely nowhere.
Now, you might realize, for example, that (in contradiction to the way this is normally done), you need to actually keep a separate record for each individual item of inventory (holding the price in that item) in order to know when it is sold - so that you won't use its price in subsequent sales.
I.e.
tblInventoryItem
ItemID, FK to master catalog item
POID, FK to purchase order where this was bought
SupplID, FK to where you got it
Cost, actual per-unit cost of this item
ItemCommit, Yes/No - Yes when item is purchased, No once item is sold.
InvID, FK to invoice where this was sold.
Now, bear with me...
When an item comes in, create ONE RECORD PER ITEM showing that this item
is NOW available (not yet committed). Mark the item as not available (committed) when you sell it. In between, the average cost for any item in your catalog is just the average cost for any available (not committed) item with a given ItemID.
OR... when filling an order, write some VBA to search this table in order of the POID field (which should be implicitly in date order, perhaps...) for items with no invoice number. If you want 10 items, take the first 10 items from this table and average their cost. Mark the item as part of the invoice. Search only items with no Invoice ID for pricing.
If you commit the invoice, go back and set the ItemCommit flag to Yes. At that point, you are done with the sale. If you cancel the invoice, you have the invoice number in the table to back out. Clear the number, and the item is back in inventory. That way, you ALWAYS have the exact price of the item available to you.
When it comes time to do DB maintenance, you can run erase queries to get rid of all items that were committed. Perhaps you can roll up those items to a separate table. I leave that detail to you.
This viewpoint might not be practical either, but then, you don't have a trivial problem. I hope your computer has a LOT of horsepower, 'cause nothing you can do is going to completely reduce the difficulty of your situation.
Also, maybe it isn't a solution now, but down the road you might wish to consider a more robust back end solution. Like SQL Server or ORACLE or one of the many other workable Access BE solutions. Because Access is not going to like handling big databases like this could get.