if statement with value

S

samuel

i have 2 standard fields
[Doses]
[TxnType]

i want to have the following occur
IF [TXNTYPE]=R
THEN [DOSES]*(-1)
ELSE [TXNTYPE]

i want to value of this to be stored in [Field3]

is this possible?
 
J

jade.skaggs

Run the following update query and it should update all of your rows as
requested.

UPDATE [MyTable] SET [Field3] =
IIf([TXNTYPE]="R",[DOSES]*(-1),[TXNTYPE]);
 
J

jade.skaggs

IIF works as follows so you can use it in a select, or anything for
that matter

IIF( [Condition] , [TRUE Branch] , [FALSE Branch] )


Run the following update query and it should update all of your rows as
requested.

UPDATE [MyTable] SET [Field3] =
IIf([TXNTYPE]="R",[DOSES]*(-1),[TXNTYPE]);
i have 2 standard fields
[Doses]
[TxnType]

i want to have the following occur
IF [TXNTYPE]=R
THEN [DOSES]*(-1)
ELSE [TXNTYPE]

i want to value of this to be stored in [Field3]

is this possible?
 
O

Ofer Cohen

Using a query you can add another field

Field3: IIF ([TXNTYPE]="R",[DOSES]*-1, [TXNTYPE])

There is no need to store a calculated field, just create a query that
display the desire resault

Select TableName.* , IIF ([TXNTYPE]="R",[DOSES]*-1, [TXNTYPE]) As Field3
From TableName
 
Top