Need help with a printing formula

Hello Friends,
I am trying to get the payor information to print on some checks.
There are several different situations, but the main fields would be:
Business Name
First Name
Last Name

No problem if all the fields are filled in.
If there is no First and Last Name then I would want:
City, State Zip

If there is no Business Name then I would want:
First Name Last Name
City, State Zip

If there is no address then I would want:
Business Name
First Name Last Name

I was looking at the “Sandwich” formula
In everything I would want the empty fields to collapse.
Any ideas would be appreciated.

I think just using CASE …do something CASE do something else ENDCASE
would work…

I don’t think we are talking about statements in a procedure, but about a formula in a Text Display object in a form. So CMTA can use some nested conditional formulas of this kind:

?(length(«First Name» = 0, «Last Name»,«First Name»+" "+«Last Name»)

Look into the yoke( function, as well as sandwich(, and the ?( conditional. They can be nested.

Sounds to me as if you’re looking for the old variable-height fields that, in P6 would expand our contact depending on their contents. Unfortunately, these have yet to be implemented. :confused:

Actually, if you are writing this on checks, it would be in text boxes on the check. You just need to write the proper formulas in the boxes.

I took over a position that requires me to write a bunch of checks, and that is what I did. In my case, I figured out what everything would say in each box, and either put it in a field, or the Formula for the box.

I haven’t forgotten about that feature – but you certainly wouldn’t want variable height for printing checks!! Checks are always going to be a fixed height.

Yes, these are where you should look. For the complicated rules you are saying you need, I think the ?( function would be the only way to do it. In Panorama X, you can have multiple nested conditions in one function, which I think might come in very handy for your application.

Kurt’s example is missing a parenthesis, here is the corrected version.

?(length(«First Name») = 0, «Last Name»,«First Name»+" "+«Last Name»)

A slightly simpler version of Kurt’s code would be

?(«First Name» = "", «Last Name»,«First Name»+" "+«Last Name»)

or even simpler:

sandwich("",«First Name»," "+«Last Name»)

All of these will omit the last name if the first name is missing. Here is another formula which will display either the first name, or the last name, or both with a space in between.

yoke(«First Name»," ",«Last Name»)

Actually, now that I look at it closer, I think the original question can be solved with the sandwich function. I do this sort of thing all the time. I am assuming that if the Address field is non blank then the City, State and Zip fields are also non-blank, if that is not true, you’ll need a slightly more complicated formula.

sandwich("",«Business Name»,cr())+
sandwich("", yoke(«First Name»," ",«Last Name»),cr())+
sandwich("",«Address»,cr()+City+", "+State+" "+Zip)

I assume you are doing this with a Text Display object, so you also might be able to simply use Literal Text mode, drop in the field names, and use the Collapse Blank Lines option.

Thank you for all the suggestions. The following is what worked for 4 different scenarios regarding names and addresses. Interesting that it made a difference at to what order they were in the formula.
Thanks for the suggestions.

?(«Business Name»="" AND «Address.1»,«First Name»+" “+«Last Name»+¶+«Address.1»+¶+«City»+”, “+«State»+” “+«Zip»,?(«Business Name»=”" AND «Address.1»="",«First Name»+" “+«Last Name»,?(«Business Name»≠”" AND «Last Name»="",«Business Name»+¶+«Address.1»+¶+«City»+", “+«State»+” “+«Zip»,?(«Business Name»≠”" AND «Last Name»≠"",«Business Name»+¶+«First Name»+" “+«Last Name»+¶+«Address.1»+¶+«City»+”, “+«State»+” “+«Zip,”"))))