If statements

Ciaran.Hudson

New member
Local time
Today, 18:42
Joined
Dec 4, 2014
Messages
7
How do you do the equivalent of an Excel If formula in Access?

In excel I have a formula in a cell (and filled down the whole column) which reads
=IF(D2="","Yes","No")

How do I create a field in a table/query in an Access table to perform the same function?
 
How do you do the equivalent of an Excel If formula in Access?

In excel I have a formula in a cell (and filled down the whole column) which reads
=IF(D2="","Yes","No")

How do I create a field in a table/query in an Access table to perform the same function?

Welcome to the forum.

This is one approach.

1. Create a query on the table in question
2. Pick the fields from your table you require to be displayed
3. In a spare "Field" cell type your expression, something along these lines,
Code:
[COLOR="Blue"]NameOfDisplayedCalculatedField[/COLOR]: IIf([[COLOR="blue"]FieldFromTable[/COLOR]]="[COLOR="blue"]SomeValue[/COLOR]","Yes","No")

nb. Change the coloured references for your specific purpose. At the very least the "FieldFromTable" will have to be modified for your purpose.

Steve.
 
I've tried to incorporate your syntax but Access doesn't like the colon ':'

This is what I tried to run.

SELECT MasterData.[User in validity]: If([User in validity]="Yes","1","2") , MasterData.[User in validity], MasterData.*
FROM MasterData;
 
Creating the query via the Query Design (QBE) view is the method I described.

If creating a direct SQL statement, then the statement should resemble this:

Code:
SELECT Table1.LastName, Table1.FirstName, IIf([Gender]="M","Yes","No") AS YourCalculatedFieldName
FROM Table1;

Again, substitute for your requirement.

Steve.
 

Users who are viewing this thread

Back
Top Bottom