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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stringing fields that can have null values 1

Status
Not open for further replies.

TimothyP

Programmer
Aug 6, 2002
135
US
My input table looks like this:

Name Street_Num Street_Prefix Street_Name Street_Suffix
Robert 234 N Elm St
Bill 125 Ranchway Ct
John 44 Oak Blvd
Tim 2365 S Watters Ave

I am trying to create a formula to string together Street_Num, Street_Prefix, Street_Name, and Street_Suffix.

The problem I am encountering is when Street_Prefix is null the formula returns a null value for my entire string formula in the report.

Any suggestions?

Thanks,
Tim
 
Try:

if isnull({table.streetnum}) then
""
else
{table.streetnum}
&
if isnull({table.streetprefix}) then
""
else
{table.streetprefix}
&
... you get the idea...

Another approach is to select File->Report Options and turn on the convert nulls to default values, which will eliminate all nulls from the report.

-k
 
On second thought, you'll probably need spaces as well:

if isnull({table.streetnum}) then
""
else
{table.streetnum}+" "
&
if isnull({table.streetprefix}) then
""
else
{table.streetprefix}+" "
&
...

-k
 
The following is what I use for my address

Code:
StringVar addr := "";

If IsNull({ADDRESSES.STREET_NUMBER}) Then
    addr := addr
Else
    addr := addr + ToText({ADDRESSES.STREET_NUMBER});

If IsNull({ADDRESSES.STREET_PREFIX}) Then
    addr := addr
Else
    addr := TrimLeft(addr +" "+{ADDRESSES.STREET_PREFIX});

If IsNull({ADDRESSES.STREET_NAME}) Then
    addr := addr
Else
    addr := TrimLeft(addr + " " + {ADDRESSES.STREET_NAME});

If IsNull({ADDRESSES.STREET_SUFFIX}) Then
    addr := addr 
Else
    addr := TrimLeft(addr +" "+{ADDRESSES.STREET_SUFFIX});

//The following is for Apartment number
if isnull({ADDRESSES.SUB_NUMBER}) then
    addr := addr
else addr := addr + " #" + {ADDRESSES.SUB_NUMBER};

If trim(addr) = "" Then
    "No address listed..."
Else
    trim(ADDR)
 
I select File->Report Options and turn on the convert DATABASE nulls values to default and it works
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top