Suppressing the # in a string if there's no data

F

FredK

I'm using Access 2003 and I'm trying to print an address on a letter. I
have a data field named "mailing_address_apt". When there's data in the
field, I'd like to have the "#" print in front of the data. And when there
is no data in the field, I don't want the "#" to print.

I'm using the below string, but it always prints the "#" whether there's
data or not.

=[mailing_address_street_name] & " #" & [mailing_address_apt]



Any help would be appreicated.
 
R

Rockn

IIF(IsNull(mailing_address_apt), [mailing_address_street_name],
[mailing_address_street_name] & " #" & [mailing_address_apt])
 
F

fredg

I'm using Access 2003 and I'm trying to print an address on a letter. I
have a data field named "mailing_address_apt". When there's data in the
field, I'd like to have the "#" print in front of the data. And when there
is no data in the field, I don't want the "#" to print.

I'm using the below string, but it always prints the "#" whether there's
data or not.

=[mailing_address_street_name] & " #" & [mailing_address_apt]

Any help would be appreicated.

you can take advantage of the fact that "#" + Null = Null

=[mailing_address_street_name] & (" #" + [mailing_address_apt])
 

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