update query based on two fields

V

Versace77

Hello:

I'm looking for help with an update query, i am looking to have a field
changed based on the value in two other fields on the same row, Column G and
Column H. I am familiar with doing an update query if it was based on the
value of just G or just H, but not both at the same time. here is an
example:

If G and H is 60 and 30 then i want column J to be 678900

Col G Col H Col J
60 30 678900
60 15 XXXXX
25 30 XXXXX

The 60, 30, is just one possible combination out of around 120.

Hope this is explained well enough. Thanks.
 
V

Versace77

Sorry, I wanted to add also, if there was a way to do this using one query
for the 120+ combinations so i don't have create 120+ separate update
queries. thank you.
 
K

KARL DEWEY

The 60, 30, is just one possible combination out of around 120.
You need to create a translation table containing the three columns. Then
use it in your update query.
In query design view it would look like this --
FIELD Col G Col H Col J
TABLE YourTable YourTable YourTable
UPDATE TO Tranlate.[Col J]
CRITERIA Tranlate.[Col G] Tranlate.[Col H]
 
J

Jerry Whittle

If the combination of Column G and H means something, you shouldn't have it
in J. Instead you should figure it out on the fly with a query.

If this was just 2 or 3 combinations, an IIf statement would be OK. If it
was a few dozen, maybe a Case statement. However you say that there is 120
combos. In this case you should list that data in another table and join them
on G and H to find out J.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top