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

how to return a different string each time a value is true 1

Status
Not open for further replies.

sfunk

Technical User
Jan 22, 2002
107
US
Hello,

I have a simple question about how to build a formula.

What I need is the first time -
Code:
{ACTION.NAME} = "Concrete"
- I want to return the string "SqFt". The second time -
Code:
{ACTION.NAME} = "Concrete"
- I want to return the string "Cubic Yards".

I tried the While/Do loop and got an error that it exceeded the number of times it will run.

This formula below returns "SqFt" each of the two times obviously. But I was hoping there was a simple way of getting it to return "Cubic Yards" the second time
Code:
{ACTION.NAME} = "Concrete
" is True.

Code:
If {ACTION.NAME} = "Concrete" Then "SqFt"

Thanks to everyone that makes a suggestion. I am monitoring responses VERY closely so if anyone has a question or needs clarification I will answer it quickly.

Cheers,
steve
 
What about the 3rd, 4th etc time. Or is there only 2?

The following will alternate between SqFt and CubicYards on each occurance of "Concrete"


stringvar print;stringvar out;

if {ACTION.NAME} <> &quot;Concrete&quot; then print:=print else
if ({ACTION.NAME} = &quot;Concrete&quot; and print= &quot;CubicYds&quot;) then print:=&quot;SqFt&quot; else
if ({ACTION.NAME} = &quot;Concrete&quot; and print=&quot;SqFt&quot;) then print:=&quot;CubicYds&quot; else
if {ACTION.NAME} = &quot;Concrete&quot; then print:=&quot;SqFt&quot; ;
if {@spu}=&quot;45111&quot; then out:=print else out:=&quot;&quot;;
out

Mike

 
Mike,

Thank you for your response.

Yes, there are only 2 cases.

It looks great, I do have a question about
Code:
{@spu}
. When I test the formula the warning box tells me the field name
Code:
{@spu}
is not known.

How should I create this formula?

Thanks again!

Steve
 
No, that shoud be the {action.name} field. {@spu} was the formula I was using to test the formula. I missed changing it when I posted. Mike

 
OK.

It runs but nothing prints. Just so you know what I did:
Pasted the formula in a formula called Material_Label and then placed the
Code:
{@Material_Label}
on the report. I placed this field in the same spot that my original formula returned the correct results, just not alternating like yours does. So I know I'm placing it in the right spot in the report. What should I try now?

Thanks,
steve
 
Did you change the &quot;45111&quot; to &quot;Concrete&quot; (another thing I neglected to change). If it doesn't find the first occurence it won't find any. Mike

 
Awesome!

It works great. Thanks for your help.

Cheers,
Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top