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

Removing space if field is null

Status
Not open for further replies.

silvionr

Programmer
May 26, 2006
3
US
I am using Crystal Reports for Visual Studio .NET 2003

I have 3 fields:
{Inform first Name} {Inform Middle Name} {Inform Last Name}

There’s one space between each field. If the field {Inform Middle Name} is null then I have 2 spaces between {Inform first Name} and {Inform Last Name} and
I would like to have only one space.
Any ideas on how to set this up?

Thank you
 
Do you mean that they are in a text object or on the report canvas?

Try creating a formula of:

whileprintingrecords;
stringvar Name:="";
if not(isnull({Inform first Name}))
and
trim({Inform first Name}) <> "" then
Name:= {Inform first Name}+" ";
if not(isnull({Inform Middle Name}))
and
trim({Inform Middle Name}) <> "" then
Name:= Name+ {Inform Middle Name}+" ";
if not(isnull({Inform Last Name}))
and
trim({Inform Last Name}) <> "" then
Name:= Name + {Inform Last Name};
Name

This will also allow for blank first and last names, and for blank fields, or those only containing spaces.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top