Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

crystal reports check null and concatenate string

Posted on 2013-05-29
5
Medium Priority
?
2,647 Views
Last Modified: 2013-05-29
Hi

I have a crystal report, (c# 2010) connecting to an access database

The report is displaying a clients address, which I ham trying to show in an unbound field

I have code like this,

{command.title} & " " & {command.fname} & " " & {command.sname} & chrW(13) 
& {command.address1} & chrW(13)
& {command.address2} & chrW(13)
& {command.address3} & chrW(13)
& {command.postcode} & chrW(13)

Open in new window


this works fine until I get a null value

how do I check for a null value and concatenate the fields as above?
0
Comment
Question by:cycledude
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 

Accepted Solution

by:
cycledude earned 0 total points
ID: 39204720
Hope this helps someone

stringVar address := "";

if not(isNull({Command.title}))then
    address := {Command.title};

if not(isNull({Command.fname}))then
    address := address & " " & {Command.fname};

if not(isNull({Command.sname}))then
    address := address & " " & {Command.sname};

address := address & chrW(13);

if not(isNull({Command.tblAppointments.address1}))then
    address := address & {Command.tblAppointments.address1} & chrW(13);

if not(isNull({Command.tblAppointments.address2}))then
    address := address &  {Command.tblAppointments.address2} & chrW(13);

if not(isNull({Command.tblAppointments.address3}))then
    address := address &  {Command.tblAppointments.address3} & chrW(13);

if not(isNull({Command.tblAppointments.postcode})) then
    address := address &  {Command.tblAppointments.postcode} & chrW(13);

address;

Open in new window

0
 

Author Closing Comment

by:cycledude
ID: 39204721
easy
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 39204735
There are 3 ways to handle this.

1.  There is an option to convert NULL to default for the entire report.  You can do this if NULL is not meaningful in the report.  In the fill version it is in the FILE --> REPORT OPTIONS

2.  In the formula editor there may be an option to USE DEFAULT FOR NULL rather than EXCEPTION FOR NULL

3.  Change the formula to

Local StringVar strOut;
If Not IsNull({command.title}) then
    strOut := {command.title};

If Not IsNull({command.fname}) then
    strOut := strOut  + " " + {command.fname};

If Not IsNull({command.sname}) then
    strOut := strOut  + " " + {command.sname};

If Not IsNull({command.address1}) then
    strOut := strOut  + chr(13) + {command.address1};

If Not IsNull({command.address2}) then
    strOut := strOut  + chr(13) + {command.address2};

If Not IsNull({command.address3}) then
    strOut := strOut  + chr(13) + {command.address3};

If Not IsNull({command.postcode}) then
    strOut := strOut  + chr(13) + {command.postcode};

Trim(strOut)

Open in new window


mlmcc
0
 

Author Comment

by:cycledude
ID: 39204801
thanks for the additional info mlmcc ;o) i would award you the points if I could
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 39204913
There is but no problem

mlmcc
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question