How to have report print only objects that have data in a certain field (not empty)

Normally, to print a report of objects that have certain data or nothing in a certain field, you would filter on the grid so that only those records show.

For example, if you want to report on all clients that have the contract Gold Service, you would filter the column Contract in the Client grid selecting the Gold Service, and only clients with this contract would show. And then you could print a list of these clients.

Or another example, if you wanted a report of all clients that did NOT have a contract at all, you would filter on the column Contract for blanks, and only clients without a contract would show so that you could print a list of these clients.

But what is the field is not an available column to filter on in that grid?

For example, what if you wanted a report that lists all clients that do not have any text in their Pop Up field. If you view your Clients grid possible columns, you will see that PopUp is not an available column so you can not filter by it.

Instead if the field is available in a detailed type report for that object, then you can create a report that uses a script to determine.

For example:

  1. Have created a detailed type report template from the Client grid that shows the client’s name and the Popup fields. If we run this report, we see that it lists clients with text in this field and clients without.

  2. So we further expand on the example scripts found in many of the sample report templates

  3. We create a Before Print script for the detailReport1 band that checks to see if there is any text in the PopUp field. And if there is not, then the report does NOT print that bands data - in other words, it does not print that client that does not have any popup

The Before Print script has the following: " "

private void OnBeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
{
//*************************
//Don’t print band if there is no text in the popup notes

object o=GetCurrentColumnValue(“LT_Client_Label_PopUpNotes”);
if(o=="")
{
e.Cancel=true;
return;
}
//**************************

}

  1. And now when we print the report, only the clients that do have text in the Popup field will print.

  2. Have attached a copy of the example report template zipped using WinZip to this forum topic. You may download and refer to it along with other examples on this forum.