Solved

# MS Access  2013

Posted on 2014-08-27
212 Views
I would like to know what formula I can use in Query calculated field for the attach example.
I would like to use  the formula where it will give me Calculated field result. "iif Status column has "N/A" then 0 otherwise give me number in the status field".

ID   Name     Status     Calculated field
12  John        100              100
13  Chris        N/A               0
14  Mathe    345               345
15  Sam        N/A              0
0
Question by:snhandle

LVL 2

Expert Comment

Refer the attached excel sheet. Just click on the "Calculated field" and see the formula.
Example.xlsx
0

LVL 47

Accepted Solution

Hi,

Supposing Status is a text field

pls try

IIf([Status]="N/A";"0";[Status])

Or

IIf([Status]="N/A";0;[Status]*1)

Regards
0

LVL 22

Assisted Solution

If you need a numeric output

IIf([Status] Is Null, 0, CInt([Status])) if the remaining values are integers,. Replace CInt with CLng if the numbers can exceeed 32767, or use CDbl if you want decimals or really large numbers.

Kelvin
0

LVL 48

Assisted Solution

I would use:

=IIf(IsNumeric([Status]),[Status],0)

/gustav
0

Author Closing Comment

Good
0

## Featured Post

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …