View Full Version : Refer to previous calculated field


captain1974
01-17-2007, 07:54 PM
Access 2003.
I was just wondering if there was any way to refer to a calculated field in the same query.
For example if the first calculated field was - Total: ([Quantity])*([Price]), could you add another calculated field - Inc Tax: ([Total])*1.175.
At present I am having to type the whole formula in the calculated field again which seems to work for some queries, but not for others, no matter how I fiddle about with the syntax. The other way is to create another query and refer to my previous query. Both these methods seem extremely cumbersome and I was wondering if I have missed something with referring to a prior calculated field.
The query above is just an example, my query formulas are actually fairly long and for editing purposes it can be difficult to correct them.

The_Doc_Man
01-17-2007, 08:56 PM
Nothing wrong with

Total: ([Quantity]*[Price]) and IncTax: (1.175*[Quantity]*[Price])

captain1974
01-17-2007, 09:44 PM
Nothing wrong with

Total: ([Quantity]*[Price]) and IncTax: (1.175*[Quantity]*[Price])

Ok, I'll be more specific. The above example is fairly simple, but when you have queries more like:
Yield/Ha: (Format(Avg([BunchCount]*10000/([RowWidth]*[VineSpacing])*([BunchWeight]/1000000)*([BlockPercent])*(1/[Half or Whole Vines])*([BlockPercent])*(1-[Missing Vine])*(1-[HarvesterLoss])*(1-[BirdLoss])*(1-[ThinningLoss])),"Standard"))
And a number of them running in sequence referring to the bulk of the last calculation it gets a bit of a headache for editing purposes. I guess I was just wondering if I was doing something wrong with syntax, if it can't be done then so be it....

Bat17
01-18-2007, 04:36 AM
what you have should work OK.
just did a quick test with
SELECT oee.ID, oee.TotalProduction, oee.PlannedProduction, [PlannedProduction]-[TotalProduction] AS total, oee.GoodProduction, [total]+[goodproduction] AS Test
FROM oee;

which ran Ok

Peter