Jumat, 15 Februari 2013

[MS_AccessPros] Dealing with spaces in a calculation

 

I'm using the following calculation to create a full address from eight
component fields and populate an AddressFull field in a table:

Trim(Nz([TEXT_RES_ADDRESS_NBR]+" ","") &
Nz([TEXT_RES_ADDRESS_NBR_SUFFIX]+" ","") &
Nz([CDE_STREET_DIR_PREFIX]+" ","") &
Nz([TEXT_STREET_NAME]+" ","") &
Nz([DESC_STREET_TYPE]+" ","") &
Nz([CDE_STREET_DIR_SUFFIX]+" ","") &
Nz([DESC_UNIT_TYPE]+" ","") &
Nz([TEXT_RES_UNIT_NBR],""))

This appears to work (sort of), as the full address is calculated without
any extraneous spaces where one or more of the component fields is NULL. It
does appear, however, to leave an empty string in AddressFull if all eight
component fields are NULL. So when I query for NULL, no records are
returned. But if I query for "", " ", " ", etc., I do find the records
where all eight fields are empty and no full address is created.

How can I modify the calculation so that I end up with a NULL (and not a
string) when all eight of the component fields are NULL.?

Access 2010.

Thanks!

James
www.james-mc.com
Words To Live By

[Non-text portions of this message have been removed]

__._,_.___
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (1)
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar