Hello
I've got an update query which I'm using to update a table when a price change takes place. It then has to do 2 things: 1.) Update the past prices. 2.) Update the current price by the percentage increase. Here's the SQL code from what I've created in the Design View:
Code:
PARAMETERS PriceIncreasePercentage Decimal, SelectSeries Text ( 255 );
UPDATE Lines SET Lines.PrevPrice3 = [PrevPrice2], Lines.PrevPrice2 = [PrevPrice], Lines.PrevPrice = [Price], Lines.PrevLanded3 = [PrevLanded2],
Lines.PrevLanded2 = [PrevLanded], Lines.PrevLanded = [Price]+[Freight], Lines.PrevDealerA3 = [PrevDealerA2], Lines.PrevDealerA2 = [PrevDealerA],
Lines.PrevDealerA = ([PrevLanded]*[DealerAMultiplier]), Lines.PrevMargin3 = [PrevMargin2], Lines.PrevMargin2 = [PrevMargin], Lines.PrevMargin =
Round((([PrevDealerA]-[PrevLanded])/[PrevDealerA])*100,2), Lines.Price = Round([Price]*(1+[PriceIncreasePercentage]/100+0.00001),2)
WHERE (((Lines.Series)=[SelectSeries]));
I think I've got this programmed correctly to update everything correctly, but I'm running into an issue of certain fields coming back with null values, specifically Lines.PrevMargin and Lines.PrevDealerA. These 2, are, of course, the ones which use other values to create a calculation for them. I think what is happening is that Access is updating things simultaneously, and the fields in use aren't populated for the calculation. What I need to happen is for things to be calculated sequentially, so that the proper fields have the right values when the calculation takes place. I know this can happen if I can some how put a "pause" or "break" in the code to have things update to a point, then run through the next round of updates/calculations.
Anyone have thoughts here?