INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Jobs from Indeed

If then else problem

If then else problem

(OP)
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

RE: If then else problem

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};

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 ""; 

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: If then else problem

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

RE: If then else problem

(OP)
lbass
Thank you so much.
I needed to do a null check on PO_No.

Not sure why though. But it's working now.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close