Solved

Access Update Query Wizard:  Multiple Criteria for same field

Posted on 2013-11-20
6
4,027 Views
Last Modified: 2013-11-20
In my update query, I have 3 requirements:
If the Country field in the Trans table is:
USA, then Base Rate field = 11%
UK, then the Base Rate field = 12%
Canada, then the Base Rate field = 13%.

Using the query builder, I listed the the Base Rate field three times (see below).  Will this work?  If not, how do I do this?  Thank you.

Tom

Field:               Base Rate    Base Rate     Base Rate
Table:              Trans            Trans            Trans
Update to:       .11               .12                .13
Criteria:           "USA"           "UK"             "Canada"
0
Comment
Question by:ThomasJue
  • 3
  • 3
6 Comments
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 39664714
Field:               Base Rate  
Table:              Trans    
Update to:      IIf([Country]="USA",.11, IIf([Country]="UK",.12, IIf([Country]="Canada",.13,Null)))

in SQL view

Update Trans Set [Base Rate]= IIf([Country]="USA",.11, IIf([Country]="UK",.12, IIf([Country]="Canada",.13,Null)))
0
 

Author Comment

by:ThomasJue
ID: 39664721
I can't do this using the Query Wizard such as below?
I realized I goofed my example in the Criteria above.  Hopefully this example is better.

Field:               Base Rate                Base Rate             Base Rate
Table:              Trans                       Trans                     Trans
Update to:       .11                          .12                         .13
Criteria:           [Trn]![Cty]="USA"     [Trn]![Cty]="UK"     [Trn]![Cty]="Canada"
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 39664732
what exactly are the names of the fields of table Trans?
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:ThomasJue
ID: 39664742
I goofed it again.  The table is Trans so the criteria should read:
[Trans]![Cty]='USA', etc.

So I am only comparing the Cty field name to see if it is USA, UK or Canada.

Thank you.
0
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
ID: 39664752
did you try the set up i posted above?

Field:               Base Rate  
Table:              Trans    
Update to:      IIf([Cty]="USA",.11, IIf([Cty]="UK",.12, IIf([Cty]="Canada",.13,Null)))
0
 

Author Comment

by:ThomasJue
ID: 39664761
Not yet.  I am waiting for the answer to the question I just posted on how to change after the Criteria line from "or" to "and".  Then I can try it.  Thanks.
0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now