Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IIF Statement Displaying Additional Records 1

Status
Not open for further replies.

awl

IS-IT--Management
Aug 2, 2001
136
US
I have two fields that I need PDMS and PDDNMS. In the 1st field, if either the Police or Driver is checked AND if FRMS is also checked, then I need a 1; the same for the 2nd field, except if FRDNMS is checked then I need a 1. However, in both statements, the results display additional records. I am wondering if is the way the formula is written. Suggestions would be helpful. Thank you.

A. PDMS: IIf([PEPolice] Or [PEDriver]=True And [FRMS]=True,1,0)

B. PDDNMS: IIf([PEPolice] Or [PEDriver]=True And [FRDNMS]=True,1,0)
 
Try these instead:

A. PDMS: IIf(([PEPolice] Or [PEDriver]) And [FRMS],1,0)

B. PDDNMS: IIf(([PEPolice] Or [PEDriver) And [FRDNMS],1,0)


Leslie
 
Leslie Thanks very much for response, it works just great. Have a pleasant day!!! Curtis...
 
Just a side note...

you can't use the Or condition like that, you have to explicitly define the or condition for each value to be tested...

so in future, remember it's:

(value1=1 OR value2=1)

Not

(value1 OR value2 = 1)
 
Crowley16: Is is then appropriate to restate the formula as: PDMS: IIf(([PEPolice]=1 Or [PEDriver]=1) And [FRMS],1,0)

Curtis....
 
It really doesn't matter when you are dealing with boolean values. When you write

Iif([PEPolice],1,0)

is the same as:

iif([PEPolice] = 1, 1, 0)

When you are dealing with text or numbers it does matter:

Iif(Field1 = "Something" OR Field1 = "Nothing", 1, 0)

Leslie
 
Thanks for clarifying. Curtis...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top