Skip line when boolean is false


I wonder if you can help me as my knowledge on scripting is limited.

I have created a custom field of type true/falsefor clients, and have generated a report which lists client names and this newcustomfield.

What I would like to do is only print the Clientwhere the custom field is True, and skip printing the line if it is either null or False.

I have read through the manual and the section ‘Preventing Bands from Displaying if a value is null’ and tried looking through other reports. I’ve been trying to use the OnBeforePrint script on the band detailBand1 but withlittle success (lack of knowledgeon C##).

I’ve attached a copy of the test report minus any script code.

Your help/advicewould be appreciated.

Regards - Brian

Hi Brian

I’ve downloaded a copy of your report template, and I’m going to have to think about this for a bit. Will get back to you as soon as I can.

  • Joyce

Hi Brian

It needed some funky stuff - I too had to ask for help from aC# guru.

Download this new report template based on yours that only prints the fields in the detailBand1 if the custom field is equal to True.

I edited the OnBeforePrint script for the detailBand1 with the following: dir=ltr " ">

private void OnBeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
//first line below gets the value of the custom field, converts it to a string, checks to see
//if it is empty or null - if empty or null, the priting of the detailBand1 is cancelled.
//the second and third line determines that if the first line was actual false (was not empty or null)
//then perform the third line which gets the string value of the custom field - if it is not True that is
//converted to a bool value of true which means the detailBand1 also doesn’t show.

e.Cancel = string.IsNullOrEmpty(GetCurrentColumnValue(“LT_Client_Label_Custom8”).ToString());
if (!e.Cancel)
e.Cancel = !bool.Parse(GetCurrentColumnValue(“LT_Client_Label_Custom8”).ToString());

}<P <P Let me know this now works for you<P - Joyce

Joyce, you’re a star ------ it works a treat.

Many Thanks