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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I am trying to replace a number of

Status
Not open for further replies.

swc123

MIS
Oct 28, 2002
51
US
I am trying to replace a number of formulas using hardcoded logic.
Grouped on FLD,
If FLD = "joe" then "Joe Adams"
elseif FLD = "pete" then "Pete Rose"
else "Unassigned".

I would like to use a reference table and then print the Full Name from that table. I'm ok for those in the Table, but am not sure how to process those names which are not in the table.
Steve
 
You'd end up using a formula something like:

(note that if you set null values to default you can omit the isnull() check in the formula)

if not(isnull({reftable.name})) and {reftable.name} <> &quot;&quot;
then
{reftable.name}
else
If {Maintable.Name} = &quot;joe&quot; then &quot;Joe Adams&quot;
else
if FLD = &quot;pete&quot; then &quot;Pete Rose&quot;
else &quot;Unassigned&quot;

Or use a case, little less effort involved:

if not(isnull({reftable.name})) and {reftable.name} <> &quot;&quot;
then
{reftable.name}
else
CASE {Maintable.Name}
WHEN &quot;Joe&quot; THEN &quot;Joe Adams&quot;
WHEN &quot;Pete&quot; THEN &quot;Pete Rose&quot;
ELSE &quot;Unassigned&quot;
END

-k kai@informeddatadecisions.com
 
Thanks, got your note in the other re-submit.

I'll have to test around some, but would I,
a) Link the tables under Database (maintable.shortname & reftable.shortname) -- this should get me JoeAdams, PeteRose, etc.
b) Use the logic with isnull you have above
finally,
c) elseif &quot;unassigned&quot;

I'm hoping to use the table for most, then Unassigned when it's not found.
 
Have I missed something?

There's nothing wrong with the original Else condition or syntax Kai supplied, if we're talking about Crystal syntax. Elseif is basic syntax.

Naith
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top