A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

update query based on two fields



 
 
Thread Tools Display Modes
  #1  
Old February 23rd, 2010, 07:14 PM posted to microsoft.public.access.queries
Versace77
external usenet poster
 
Posts: 10
Default update query based on two fields

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.
  #2  
Old February 23rd, 2010, 07:32 PM posted to microsoft.public.access.queries
Versace77
external usenet poster
 
Posts: 10
Default update query based on two fields

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.

"Versace77" wrote:

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.

  #3  
Old February 23rd, 2010, 07:41 PM posted to microsoft.public.access.queries
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default update query based on two fields

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]

--
Build a little, test a little.


"Versace77" wrote:

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.

  #4  
Old February 23rd, 2010, 07:44 PM posted to microsoft.public.access.queries
Jerry Whittle
external usenet poster
 
Posts: 4,732
Default update query based on two fields

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.
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


"Versace77" wrote:

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.

  #5  
Old February 23rd, 2010, 09:27 PM posted to microsoft.public.access.queries
Versace77
external usenet poster
 
Posts: 10
Default update query based on two fields

Karl and Jerry, thank you both for helping me here and sharing the sound
advice.

"Jerry Whittle" wrote:

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.
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


"Versace77" wrote:

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.

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 08:02 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.