Conditional printing depending of empty or null value in Crystal Reports

会有一股神秘感。 提交于 2019-12-24 06:48:37

问题


Suppose I have an StoredProcedure that returns a unique row corresponding to a table with columns "Name" and "Surname".

I want the report to show:

Name: NameField
Surname: SurnameField

Where the "NameField" and "SurnameField" are the fields returned by the StoredProcedure.

The special requirement, is that if "SurnameField" is empty or null, then I don't want to show the "Surname: SurnameField".

How can I achieve this? The only thing that I thought is breaking the storedprocedure in two, one for Name and one for Surname, and dividing each line in different subreports and selecting "Delete if empty" (or something like that) for the second... but this is really overkill, I guess there's an easier way.


回答1:


Should be quite a few ways of achieving this. I'm not quite sure how your report is laid out but you can surpress the field and label or entire section (if it has it's own) using a simple formula; isnull({table.field}) or {table.field} = ''

Or if you have set nulls to be treated as defaults rather than exceptions you can simply do: {table.field} = ''

L




回答2:


Set the field > 1 (assuming all is greater than 1 already) or <> 0.
That should filter out records with a blank in that area.




回答3:


You can achieve it by Section Expert:

Supposing the name field name is Surname and the table is NAME and the field storing the value of surname is S_NAME_VALUE. You can put up the filter checking if the value is NULL or BLANK.

if {NAME.SURNAME} in ['SNAME'] and 
             {NAME.S_NAME_VALUE} =''
then 
             TRUE

I am assuming there are some codes for Surname filtering i.e SNAME.

If not you can use the one condition and mark it as true.

  if {NAME.S_NAME_VALUE} = '' then TRUE


来源:https://stackoverflow.com/questions/10567918/conditional-printing-depending-of-empty-or-null-value-in-crystal-reports

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!