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

Nested formulas for Record Selection

Status
Not open for further replies.

jtflex

Technical User
Feb 20, 2004
32
US
Hi everybody.

I am trying to solve a problem that involves the reading of a parameter field {?CaseNumber} typed in by a user and coverting it to the proper format before querying the database for that record. I am using CR 9.0 and have acess to a Oracle Database.

The datafield is a 9 Numberic (string)that tracks a report number. The first two numbers represent the year and the last seven are the report number (example: 040053297 means the year 04 and report number 53297).

Hand written reports look as such: 04-53297.

I wrote three formulas so a user at a prompt could type: 04-53297 or 53297 or even 040053297. Each formula works fine by itself.

The problem I'm having is trying to nest all three formulas together into a larger one using If's Else statements to call each formula.

Here's what it looks like:

{@Find Hyphen};
If {@Find Hyphen} then
{@Convert Full Case Number}
ELSE
If length({?CaseNumber}) <= 7 then
{@Convert Short Case Number}
ELSE
{?CaseNumber}

When I run this formula, the {@Convert Full Case Number} still tries to execute even though {@Find Hyphen} is FALSE.

Is this the wrong way to nest formulas to control which one executes?


Thank you for your time.

Joe
 
What is the formula for {@FindHyphen}?

Also, instead of calling the formula, you could just use this as the first line of your If statement:

If InStr({?CaseNumber}, '-') > 0 then...


-D
 
The InStr command you listed without the If & then is my
{@FindHyphen} formula.

I did it this way to try to make the formulas look clean to the eye when viewing them.

By the way, I did try it with the InStr command like you asked and the program still tried to run
the formula {@Convert Full Case Number}

Joe
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top