Using MS Access/If statement

Advertisement


Question
Hi,

Can you properly review and format the following statement for me please?

If([location1]=College and [location2 ]= Jamaica enter [QC] (if [location1]=Jamaica and [location2]=College enter [exp1], (if [location1] =Flushing and [location2 ]= college enter [Flu] (if [Location1] =College and [location2]= Flushing enter [Expr2]))))

Thanks in advance,
Randy

Answer
Try it this way:

IIf([location1]="College" AND [location2]="Jamaica", [QC], IIf([location1]="Jamaica" AND [location2]="College", [exp1], IIF([location1] ="Flushing" AND [location2]="College",[Flu], IIF( [Location1] ="College" AND [location2]= "Flushing", [Expr2],"N/A"))))

This assumes that QC, exp1, Flu and Expr2 are column names in the query.

Using MS Access

All Answers


Answers by Expert:


Ask Experts

Volunteer


Scottgem

Expertise

I can answer almost all types of questions relating to Microsoft Access usage and application design. My strengths are database and interface design.

Experience

I've been designing databases for over 25 years working with dBase, FoxPro, Approach and Access.

Organizations
Author of Microsoft Office Access 2007 VBA
Techncial Editor for Special Edition Using Microsoft Access 2007 and Access 2007 Forms, Reports & Queries From Que Publishing

Education/Credentials
Brooklyn College BA

©2016 About.com. All rights reserved.