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

If then else problem 1

Status
Not open for further replies.

smeyer

IS-IT--Management
Nov 15, 2002
52
0
0
US
I am trying to create a formula that chacks the value of PROF_ALPHA_1 and modifies it if needed based on its value. Then the same thing with the PO_NO. Finally returns either PROF_ALPHA_1, PO_NO or PROF_ALPHA_1/PO_NO based on whether fields are empty or not.

My problem lies with the SP variable for some reason. If both PROF_ALPHA_1 and PO_NO have values it works great. If PO_NO has a value but PROF_ALPHA_1 does not it works great. But if PROF_ALPHA_1 has a value and PO_NO does not it gives me a blank.

<code>
Local StringVar PO;
Local StringVar SP;

if isnull({PROF_ALPHA_1}) then SP:=""
else if {PROF_ALPHA_1} startswith "SP" then SP := {PROF_ALPHA_1}
else if {PROF_ALPHA_1} <> "" then SP := "SP" + {PROF_ALPHA_1}
if {PO_NO} <> "" then PO := {PO_NO}
else PO := "";
if (PO <> "" and SP <> "") then SP + "/" + PO
else if (SP <> "") then SP
else if (PO <>"") then PO
else "";
</code>

Any idea what's going on?

Thanks
Steve
 
hi,

Code:
if isnull({PROF_ALPHA_1}) then SP:="" 
else if {PROF_ALPHA_1} startswith "SP" then SP := {PROF_ALPHA_1}
else SP := "SP" + {PROF_ALPHA_1}[highlight #FCE94F];[/highlight]

if {PO_NO} <> "" then PO := {PO_NO}
else PO := "";

if (PO <> "" and SP <> "") then SP [highlight #FCE94F]+[/highlight] "/" + PO
else if (SP <> "") then SP
else if (PO <>"") then PO
else "";


Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
You need to to do a null check on {PO_No} too.

If isnull({PO_No}) or
{PO_No}="" then
PO := "" else
PO := {PO_No};

-LB
 
lbass
Thank you so much.
I needed to do a null check on PO_No.

Not sure why though. But it's working now.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top