Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If then Formula Help

Status
Not open for further replies.

rahartigan

Technical User
May 10, 2012
5
US
I'm trying to display on a report the defendant name and the plaintiff name separately. The field that distinguishes them is involvement type. I can display the Plaintiff name but the Defendant isn't working. I know I am missing something easy as this is one of the more complex formulas I need to do. Any assistance is appreciated. The formula I am trying is below.

Thanks.

WhilePrintingRecords;

stringVar Defendant;

If {Civil_Name.Involvement_Type}= 'Defendant' then Defendant;

if not isnull ({Civil_Name.Business_Name})
then Defendant := {Civil_Name.Business_Name}

else Defendant := {Civil_Name.Name_Last};

If not isnull ({Civil_Name.Name_First}) THEN Defendant := Defendant & " " & {Civil_Name.Name_First};

If not isnull ({Civil_Name.Name_Middle}) THEN Defendant := Defendant & " " & {Civil_Name.Name_Middle};

If not isnull ({Civil_Name.Name_Suffix}) THEN Defendant := Defendant & " " & {Civil_Name.Name_Suffix};

Defendant := TRIM(Defendant);
Defendant;
 
So what is not working. FYI: Do you have "Default Values for Nulls" selected in the formula workshop?
 
Keep in mind that if statements terminate as soon as the first true condition is met, so I don't think you're getting past this line for records where the Involvement Type is Defendant:

If {Civil_Name.Involvement_Type}= 'Defendant' then Defendant;

I think by moving that line to the end you'll get what you want:

Code:
WhilePrintingRecords;

 stringVar Defendant;

[b] If {Civil_Name.Involvement_Type}= 'Defendant' then Defendant;[/b] 

 if not isnull ({Civil_Name.Business_Name})
 then Defendant := {Civil_Name.Business_Name}

 else Defendant := {Civil_Name.Name_Last};

 If not isnull ({Civil_Name.Name_First}) THEN Defendant := Defendant & " " & {Civil_Name.Name_First};

 If not isnull ({Civil_Name.Name_Middle}) THEN Defendant := Defendant & " " & {Civil_Name.Name_Middle};

 If not isnull ({Civil_Name.Name_Suffix}) THEN Defendant := Defendant & " " & {Civil_Name.Name_Suffix};

 Defendant := TRIM(Defendant);

[b] If {Civil_Name.Involvement_Type}= 'Defendant' then Defendant else "";[/b]

This still may not work perfectly but you get the idea.


 
Well I screwed that up, but now I'm not convinced that's the issue. But try it anyway, sorry I don't have time to test it properly.


WhilePrintingRecords;

stringVar Defendant;

if not isnull ({Civil_Name.Business_Name})
then Defendant := {Civil_Name.Business_Name}

else Defendant := {Civil_Name.Name_Last};

If not isnull ({Civil_Name.Name_First}) THEN Defendant := Defendant & " " & {Civil_Name.Name_First};

If not isnull ({Civil_Name.Name_Middle}) THEN Defendant := Defendant & " " & {Civil_Name.Name_Middle};

If not isnull ({Civil_Name.Name_Suffix}) THEN Defendant := Defendant & " " & {Civil_Name.Name_Suffix};

Defendant := TRIM(Defendant);

If {Civil_Name.Involvement_Type}= 'Defendant' then Defendant else "";
 
if Civil_Name.Involvement_Type is null, the formula will die on the first line. Either put your null test first, or use the "Convert Nulls to Default Values" option.
 
Involvement Type should never be null so that sort of helps and you all right...I am seeing the Plaintiff information on both lines.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top