IIF function in a report

S

sue

Am familiar with If together with the And function in
Excel for having two criteria be true to determine an
outcome. Can I do the same thing in Access?
 
J

Jan

Am familiar with If together with the And function in
Excel for having two criteria be true to determine an
outcome. Can I do the same thing in Access?

Sue,
Yes, but how is determined by where.
In VBA event you could use either If .. Then .. Else or IIF().

If [Lastname] = "Smith" and [FirstName] = "John" then
' Do this
Else
' Do that
End if

or...
in VBA or as a Control's Control Source expression:
=IIf([LastName] = "Smith" and [FirstName] = "John,Do True Part,Do
False Part)

In a Query..
Exp:IIf([LastName] = "Smith" and [FirstName] = "John,Do True Part,Do
False Part)
 
D

Duane Hookom

Jan,
You missed the quote after John:
=IIf([LastName] = "Smith" and [FirstName] = "John", Do True Part, Do False
Part)


--
Duane Hookom
MS Access MVP


Jan said:
Am familiar with If together with the And function in
Excel for having two criteria be true to determine an
outcome. Can I do the same thing in Access?

Sue,
Yes, but how is determined by where.
In VBA event you could use either If .. Then .. Else or IIF().

If [Lastname] = "Smith" and [FirstName] = "John" then
' Do this
Else
' Do that
End if

or...
in VBA or as a Control's Control Source expression:
=IIf([LastName] = "Smith" and [FirstName] = "John,Do True Part,Do
False Part)

In a Query..
Exp:IIf([LastName] = "Smith" and [FirstName] = "John,Do True Part,Do
False Part)
 
F

fredg

Jan,
You missed the quote after John:
=IIf([LastName] = "Smith" and [FirstName] = "John", Do True Part, Do False
Part)

Thanks, Duanne,
Actually Jan didn't miss it, I did. I inadvertently used her identity
to post. I hope she doesn't start getting spam now.
 
Top