Solved

IIF looking at two different fields

Posted on 2011-03-23
5
389 Views
Last Modified: 2012-05-11
I need to use an IIF that looks at two fields as in:

Expr2: IIf((Len([phone#])=7) And Mid$([TextField],1,4)='CRED',result1,result2)

all I get is result2
0
Comment
Question by:stirus
5 Comments
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Access MVP) earned 42 total points
ID: 35200772
Try with double quotes:
Expr2: IIf((Len([phone#])=7) And Mid$([TextField],1,4) = "CRED",result1,result2)

But are you SURE the condition is actually being met?

mx
0
 
LVL 77

Assisted Solution

by:peter57r
peter57r earned 42 total points
ID: 35200826
I agree with mx's last comment.

I think you are misreading your data.

Add the expressions temporarily as extra columns and see..

mylen:Len([phone#])

mymid: Mid$([TextField],1,4)
0
 
LVL 44

Assisted Solution

by:GRayL
GRayL earned 41 total points
ID: 35200959
Try this.  I moved the parentheses:

IIf((Len([phone#])=7 And Mid$([TextField],1,4)="CRED"),result1,result2)
0
 

Author Closing Comment

by:stirus
ID: 35201006
all three helped.  Thanks
0
 
LVL 44

Expert Comment

by:GRayL
ID: 35201275
Thanks, glad to help.  Can you post Expr2 as you now have it?
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

778 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question