Introducing a condition into an expression

W

Winefride

I have an expression eg Expr1: [Donor1First Name] & " and " &
[Donor2FirstName]
I dont want the word "and" to appear if [Donor2FirstName] is null.
Any ideas?
Thanks in advance for any help.
 
K

Klatuu

Expr1: [Donor1First Name] & IIf(IsNull([Donor2FirstName]),""," and " &
[Donor2FirstName])
 
F

fredg

I have an expression eg Expr1: [Donor1First Name] & " and " &
[Donor2FirstName]
I dont want the word "and" to appear if [Donor2FirstName] is null.
Any ideas?
Thanks in advance for any help.

There are a couple of ways.
1)
Expr1:IIf(IsNull([Donor2FirstName]),[Donor1firstName],
[Donor1FirstName] & " and " & [Donor2FirstName])

or you could use:

Expr1:[Donor1FirstName] & (" and " + [donor2FirstName])
 
W

Winefride

Thank you very much.
--
Winefride


Klatuu said:
Expr1: [Donor1First Name] & IIf(IsNull([Donor2FirstName]),""," and " &
[Donor2FirstName])
--
Dave Hargis, Microsoft Access MVP


Winefride said:
I have an expression eg Expr1: [Donor1First Name] & " and " &
[Donor2FirstName]
I dont want the word "and" to appear if [Donor2FirstName] is null.
Any ideas?
Thanks in advance for any help.
 
W

Winefride

Thank you very much.
--
Winefride


fredg said:
I have an expression eg Expr1: [Donor1First Name] & " and " &
[Donor2FirstName]
I dont want the word "and" to appear if [Donor2FirstName] is null.
Any ideas?
Thanks in advance for any help.

There are a couple of ways.
1)
Expr1:IIf(IsNull([Donor2FirstName]),[Donor1firstName],
[Donor1FirstName] & " and " & [Donor2FirstName])

or you could use:

Expr1:[Donor1FirstName] & (" and " + [donor2FirstName])
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top