?
Solved

C# Crystal Reports

Posted on 2011-04-25
6
Medium Priority
?
321 Views
Last Modified: 2012-08-14
I have a couple of problems hince the high point total!!  :)
First:
I have an address section with:
Name
Address
Address2 CityStateZip
CityStateZip
What I would like to do is if Address2 is empty Suppress it and unSuppress CityStateZip which is on top of Address2 and Suppress the bottom CityStateZip.  If Address2 is not empty then unsuppress it and suppress the CityStateZip that is on the same line.

Second.
I have a form named frmTabbedSetup with  a control named chkPrintAddress.  On this rptStatement I have another address block that I want to display if chkPrintAddress is checked and have it hidden or suppressed if chkPrintAddres is not checked.

Thanks a bunch for all ya'll previous help!!  You've been a godsend!!

Jerry
0
Comment
Question by:JDL129
  • 3
  • 3
6 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 35462868
Suppression -
2 ideas
1.  Put each field in its own section
     Use the section expert to SUPPRESS BLANK SECTIONS

2.  Create a formula to combine the fields into a single string
Something like
WhilePrintingRecords;
Local StringVar strAddress;
strAddress := {NameFIeld} & chr(13) & {AddressField} & chr(13);
If NOT IsNull({Address2Field}) then
    strAddress  := strAddress  & {Address2Field} & chr(13);
strAddress := strAddress  & {CItySteatZip};
strAddress

mlmcc
0
 

Author Comment

by:JDL129
ID: 35463720
mlmcc!!  Thanks for you response!!!!!!!!!!!

I need an else I think if Address2 is empty?
WhilePrintingRecords;
Local StringVar strAddress;
strAddress := {sp_Statement;1.Fullname} & chr(13) & {sp_Statement;1.ADDRESS};
If NOT IsNull({sp_Statement;1.ADDRESS2}) then
    strAddress  := strAddress  & {sp_Statement;1.ADDRESS2} & chr(13);
    strAddress := strAddress  & {sp_Statement;1.CITY} & " " & {sp_Statement;1.STATE} & " " & {sp_Statement;1.ZIP}
ELSE
    strAddress  := strAddress  & {sp_Statement;1.ADDRESS2} & chr(13);
    strAddress := strAddress  & {sp_Statement;1.CITY} & " " & {sp_Statement;1.STATE} & " " & {sp_Statement;1.ZIP};

From ELSE and down I get: The remaining text does not appear to be part of the formula.

How do I do the second part of my question?

Thanks for your help!!!!
Jerry
0
 
LVL 101

Accepted Solution

by:
mlmcc earned 2000 total points
ID: 35464425
My code should work.

WhilePrintingRecords;
Local StringVar strAddress;
strAddress := {sp_Statement;1.Fullname} & chr(13) & {sp_Statement;1.ADDRESS} & chr(13);
If NOT IsNull({sp_Statement;1.ADDRESS2}) then
    strAddress  := strAddress  & {sp_Statement;1.ADDRESS2} & chr(13);
strAddress := strAddress  & {sp_Statement;1.CITY} & " " & {sp_Statement;1.STATE} & " " & {sp_Statement;1.ZIP};
strAddress


To answer why  the error, Crystal uses ( ) when the then or else needs more than 1 statement.  Your else and then parts are identical.  ALso when Crystal tries to concatenate the NULL field into the address it will terminate execution and return an undetermined value.  Probably nothing.

Here is how you would do yours.
WhilePrintingRecords;
Local StringVar strAddress;
strAddress := {sp_Statement;1.Fullname} & chr(13) & {sp_Statement;1.ADDRESS};
If NOT IsNull({sp_Statement;1.ADDRESS2}) then
(
    strAddress  := strAddress  & {sp_Statement;1.ADDRESS2} & chr(13);
    strAddress := strAddress  & {sp_Statement;1.CITY} & " " & {sp_Statement;1.STATE} & " " & {sp_Statement;1.ZIP}
)
ELSE
(
    strAddress  := strAddress  & {sp_Statement;1.ADDRESS2} & chr(13);
    strAddress := strAddress  & {sp_Statement;1.CITY} & " " & {sp_Statement;1.STATE} & " " & {sp_Statement;1.ZIP};
);
strAddress  

mlmcc
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:JDL129
ID: 35466753
mlmcc!!!!  Thanks for the response!!!
That works great.  To the second part of my original question how do I suppress this if chkPrintAddress on frmTabbedSetup is not checked?

Thanks for the response!!!
Jerry
0
 
LVL 101

Assisted Solution

by:mlmcc
mlmcc earned 2000 total points
ID: 35467590
You will have to pass a parameter to the report with the value of checked or unchecked and conditionally suppress using that or use that in the formula to not build the address.

mlmcc
0
 

Author Closing Comment

by:JDL129
ID: 35494484
OOPS!!!  Sorry, forgot to close it out.

Jerry
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses
Course of the Month15 days, 14 hours left to enroll

850 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