ScoobyNet.com - Subaru Enthusiast Forum

ScoobyNet.com - Subaru Enthusiast Forum (https://www.scoobynet.com/)
-   Computer & Technology Related (https://www.scoobynet.com/computer-and-technology-related-34/)
-   -   Any Access 2002 gurus out there? (https://www.scoobynet.com/computer-and-technology-related-34/295653-any-access-2002-gurus-out-there.html)

awd2000 25 January 2004 11:42 PM

Probably being very dense but...

If I update a database table field in an "update" action
query, how do I get it to use the updated value of this field
in another "update to" expression in the same query?

At the moment I'm only getting the "before update" value
of the first field being used in the update expression of
the second one.

GaryK 26 January 2004 08:04 AM

Its not possible, each SQL command is a unit of work or a transaction, the new values will not get applied to the columns until the whole statement has executed this isnt an access 2002 issue its standard SQL. Can you post what it is you are trying acheive maybe another way.

cheers

Gary

awd2000 26 January 2004 08:32 PM

Thanks Gary

In a single-pass update query I am trying to..
1. Set 'Price' to a new value from a fairly complex calc
2. Set 'VAT' to 17.5% of this new value
3. Set 'Total' to the new value of 'Price' plus the calc value of 'VAT'

For a number of arcane reasons, the underlying table fields can't have expressions associated with them, hence using a query.

I've worked around the problem by...
1. Setting 'Price' =(complex calc expression)
2. Setting 'VAT' = (complex calc expression)*0.175
3. Setting 'Total' =((complex calc expression)+((complex calc expression)*0.175)

Not very elegant and a pain to maintain!

GaryK 27 January 2004 08:29 AM

No problem, one of the industry strength DBMS such as SQL server would let you get around this by using stored procedures which would let you store these calcuations in variables before running the update statement. Dont know if you know but you can get a cut-down version of SQL Server called MSDE which is a free download. It makes deployment a little trickier but is way more robust and scalable than an access solution.

cheers

Gary

awd2000 27 January 2004 08:26 PM

Thanks - I'll get this round of changes done and dusted and then I guess it's time to play with a real RDBMS!

Cheers


All times are GMT +1. The time now is 10:47 AM.


© 2024 MH Sub I, LLC dba Internet Brands