Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Conditional updating 1

Status
Not open for further replies.

mypeljo

Technical User
Apr 16, 2010
12
BG

I have the following working updating function which is ok:

CurrentDb.Execute "UPDATE Products SET office = products.grossprice*0.72"

I want to add on a condition depending on the field “code” in the same table products. But I do no know how to do it.I do not want to use a form but otherwise is it possible to do it ?
What I want to achieve is the following:

If Products.code = 10153 or Products.code = 10567 or Products.code = 324555 Then
CurrentDb.Execute "UPDATE Products SET office = products.grossprice*0.72"
Else
CurrentDb.Execute "UPDATE Products SET office = products.grossprice*0.9"

How can I do it with Currentdb.execute command?
 
How are ya mypeljo . . .

... and this:
Code:
[blue]CurrentDb.Execute "UPDATE Products SET office = IIf([purple][b]Products.Code IN (10153,10567,324555)[/b][/purple],products.grossprice*0.72,products.grossprice*0.9)", dbFailOnError[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top