Field Return Different Values

kcyankees125

Registered User.
Local time
Yesterday, 21:19
Joined
Nov 20, 2012
Messages
11
I have a table [DATA] that has a Field named
Code:
 with each record having a value from 0-9.  I would like a query that creates a new field called [TYPE] that shows a D if the [CODE] value is 0 and shows an I for everything else.  How can I do I do this?
 
Create the new field in your table first. Then create an UPDATE query to UPDATE the new field. How?

Create a normal query using your table [DATA]. Select
Code:
 and your new field [TYPE]. Once done, open the query in DESIGN view and select Update Query form the menu or toolbar. This will give you an extra row [B]UPDATE TO[/B] below the table name row. Type "D" in the box below [TYPE]. In the Criteria section below [CODE] type =0. When run, this will update TYPE to D. Now change "D" to "I" and change =0 to <>0.
 
SQL for D
[CODE]UPDATE DATA SET DATA.TYPE = "D"
WHERE (((DATA.CODE)=0));

SQL for I
Code:
UPDATE DATA SET DATA.TYPE = "I"
WHERE (((DATA.CODE)<>0));
 

Users who are viewing this thread

Back
Top Bottom