Ok the problem here (at least with your example) is that neither table has a primary key defined. The only way I am aware of to create an update/updateable query is to link through the PK of the child table, in your case table SALE. That does not help you with your query. I think what I would do if you
a. Want to do this with queries
b. Want to do this with your current data structure
would be to figure the discount price BEFORE adding it to the temp table in the first place. Is that a possibility for you? Then you could create the calculated value and append it without issue.
Otherwise I don't know of a way to do this with no primary key defined. Your other option is to set the primary key of the SALE table to be a a combination of the ID and ITEM field as it looks like you're storing a history of sale dates and percentages.
So this is what I did to get a working query:
1. In the properties of the SALE table I made the ID and ITEM fields the primary key (normally you do NOT want to create a dual primary key, we're just trying to get this working right now)
2. In the TEMPTBL table I created a new field PRICE2, this is the field i'll be updating so you can keep the original value of your sale price)
3. Used this query to update TEMPTBL:
Code:
UPDATE TempTbl LEFT JOIN Sale ON TempTbl.ITEM = Sale.ITEM SET TempTbl.Price2 = [price]*(1-([sale]/100));
Now. Just a few things of note here.
1. There is really no reason to perform this update. What you are doing is storing a calculated value with no audit trail to help you get back to why the price was altered. I don't know if that's an issue for you but personally I would leave the sale price alone and calculate the discount on whatever form/report you need to.
2. Storing the text value of your item is a bad idea, what you really should be doing is storing your item's primary key (autonumbers are a great PK), You want to use a value that has no chance of being altered as your database expands. In your tables, if you change item the name of an item from XXXXXX to YYYYYYY you are going to orphan a bunch of your data, making it unusable. If you store the PK of the item you will not run this risk.
3. The query I gave you does not account for whether or not the sale of the item fell within the range of the sale, nor does it take into account the criteria of selling x amount of dollars worth of the product (or does the 'criteria' field mean your total bill has to be at least x).