Tamal
Tamal

Reputation: 25

How to show and hide a LineObject by using formula in crystal report?

I'm using a Crystal Report connected with VB.NET 2010, here I using a Line object, which I need to show or hide depending on data field. Where do I need to set the formula?

This project I use is running with SQL 2008 and VB.NET 2010. I've tried some Formula Field for this topic. But the result is not look like that I want to show. I use the following code on Formula Field:-

IF isNull({PrintParticularList.CUST_INVOICE_No}) or {PrintParticularList.CUST_INVOICE_No}=""
THEN 
""
ELSE 
"--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------"

I also try this following Code :-

IF isNull({PrintParticularList.SLNO}) or {PrintParticularList.CUST_INVOICE_No}=""
THEN 
Line25.Suppress=True
ELSE 
Line25.Suppress=False

But here I got error on Line25.

A number, currency amount,boolean, date, time, date-time, or string is expected here.

Upvotes: 0

Views: 2728

Answers (1)

R. McMillan
R. McMillan

Reputation: 1422

In the Report Designer use the Insert Line tool to draw the line where you want it to appear on your report. The right-click the line object and select "Format Line..." to open the Format Editor dialog box. On this window you will find a check box labeled "Suppress" with an X-2 button to the right. Click the X-2 button and this will open a Formula Workshop window where you will enter the formula that determines if this drawing object should be suppressed or not.

I would recommend the following formula based upon your previous attempts at creating one.

IF isNull({PrintParticularList.SLNO}) or {PrintParticularList.CUST_INVOICE_No}="" THEN 
     True
ELSE 
     False

-----EDIT-----

Since you don't have the X-2 button I have 2 more ideas.

1.) Take the 1 section you current have and split it into 3 sections. Then you could place all the content above the line in the first section, place the line in the second section, and the content below the line in the third section. They use the formula to suppress the second section when the line is not needed.

2.) Insert a blank text box in place of the line and set either the top or bottom border of the text box to a single line. Then use the suppress formula to determine if the text box should be shown or hidden.

Upvotes: 1

Related Questions