473,836 Members | 1,560 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to write an if statement in an update query.

12 New Member
Here's what I need to happen in my table: if field 4 = DP I need field 2 to equal 02 else equal 10.

Simple right?
May 10 '11 #1
5 14423
12,516 Recognized Expert Moderator MVP
The IIF function syntax is
IIf(true/false expression, true value, false value)
May 10 '11 #2
12 New Member
I don't understand how to write what you are suggesting. Can you write it for me using my data?
May 10 '11 #3
12,516 Recognized Expert Moderator MVP
Sorry but that's not what I do. I will guide you towards the answer if you show that you're willing to put in the work to arrive at the answer. But I will not give out the answer.
May 10 '11 #4
12 New Member
Nevermind Rabbit, I figured it out. I used:
Expand|Select|Wrap|Line Numbers
  1. IIf("USER FIELD 4]"="DP","02","10")
Thank you for your help!!
May 10 '11 #5
32,584 Recognized Expert Moderator MVP
I'm afraid that doesn't work. It couldn't possibly as it always returns a FALSE result ("USER FIELD 4]" can never be equal to "DP"). Do you possibly mean :
Expand|Select|Wrap|Line Numbers
  1. IIf([USER FIELD 4]="DP","02","10")
May 11 '11 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

by: rrh | last post by:
I am trying to update a field in one table with data from another table. The problem I'm running into is I need to base the update on a range of data in the 2nd table. Table 1 has: date field new field table 2 has: key field (autonumber)
by: Megan | last post by:
hi everybody- it seems like my update query should work. the sql view seems logical. but that might be up to discussion...lol...i'm a newbie! UPDATE , Issue SET .IssueID = . WHERE ((.=.));
by: Greg Strong | last post by:
Hello All, In an 'Update' query can you use user-defined functions in the 'Update To' for the query? Either no or I'm missing something. See the additional info below. If I run a query as a select query it runs fine. The select query is as follows:
by: fong.yang | last post by:
I have two tables that I need to compare. Table1 is Regions table which contains state, zipcode, city, and region number. Table2 is Shops which contains multiple fields plus state and zipcode, and city. I'm trying to write an update query between the two tables. If Shops table city, state, and zip are the same as regions' table city, state, and zip then I want the region number from the regions table updated to the shops table in the...
by: arion | last post by:
Hello, I am working on a very complex database and now I am trying to create an update query. The query is showing too few records. I am trying to update data in the table "inventory" with data from "workorder" table. The query is just copying the last workorder. I would like to update all new workorders to the inventory (can be until 100 records). I would really appreciate your help! Thank you! Imke
by: aaronvb | last post by:
Hi there, I'm currently trying to fix up a database that has had many different people work on it and therefore is confusing me no end. Currently i am trying to update a field, in the table . is a numeric field and is linked to the (its the PK)
by: dee | last post by:
I have a table 'LeadHistory' which has among others, the following fields. Salesman(Text) SalesmanAssmntDate(Date/Time) Disposition(Text) I also have a table 'LookUpSalesman' which has among others, these following fields.
by: jpatchak | last post by:
I want to write an update query that updates fields from one table to another. The first table (tblCopyFrom) is in a one-to-one relationship with the 2nd (tblCopyTo). The primary key in tblCopyFrom is stored in a foreign key field in tblCopyTo. I want the query to update tblCopyTo to values of the corresponding record in tblCopyFrom where the names of the fields in each table are the same. I know how to do this in VBA with ADODB recordsets,...
by: jrsonner | last post by:
I have multiple entries in one table that I need to update the entries in the current production table with, to revert that data back before a migration so I can migrate that data again. The queries I wrote to find the entries that need to be updated is below. There are four queries that I ran to find the information. There is a total of about 2500 lines that need to be updated. Select * from St_Page where fname like '01-%' Select *...
by: srinit | last post by:
hi i have a table like col1 col2 col3 col4 35 R 0 0 36 W 1 35 37 R 0 0 38 W 2 35,36 I am giving col1 value 35 as input
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.