I am trying to write an IF statement using FormCalc in LiveCycle. I have cell "tpe" which captures total points. I would like to assign levels based on the number of points achieved. For example, level I = 1001-1985; level II = 851-1000; level III = 551-850; level IV = <551. I want cell "level" to show either I, II, III or IV, based on the points in cell "tpe". How can I do this? I have zero familiarity with FormCalc or scrips in general. Can someone please help me with this? Would appreciate any help!! Thanks!
Solved! Go to Solution.
Views
Replies
Total Likes
Just put the script into the calculate field of level instead:
if (tpe > 1000 and tpe <= 1985) then
$ = "I"
elseif (tpe > 850 and tpe <= 1000) then
$ = "II"
elseif (tpe > 550 and tpe <= 850) then
$ = "III"
elseif (tpe <= 550) then
$ = "IV"
else $ = ""
endif
Also just having a look at your form - for next time you could have saved yourself a whole lot of time in your setup by using tables for all those fields rather than making each one a seperate numeric field.
Views
Replies
Total Likes
in the exit event of "tpe" put:
if ($ > 1000 and $ <= 1985) then
level = "I"
elseif ($ > 850 and $ <= 1000) then
level = "II"
elseif ($ > 550 and $ <= 850) then
level = "III"
elseif ($ <= 550) then
level = "IV"
else level = ""
endif
(this assumes the user is entering the amount in the tpe cell. If it is worked out by a calculation you can use the same code but put it in a different event depending on what you are doing)
Views
Replies
Total Likes
Thank you very much for your quick response! Although I've stopped getting all the syntax errors that my own feeble attempts were generating, the script didn't work.
"tpe" is a calculated - read only cell that sums the values of 10 other cells. I want the result I, II, III, or IV to appear in cell "level," based on the total in "tpe". I tried different events as you suggested, but nothing. What can you suggest? Thanks in advance.
Views
Replies
Total Likes
you can put that code in the calculation event of tpe after the code you already have to work out the value of tpe
Views
Replies
Total Likes
Thank you so much!!! That worked...sort of. Now no matter what the sum of the 10 cells, "tpe" shows a result of zero and "level" shows as "IV". Am I missing something or doing something wrong?
Views
Replies
Total Likes
level is showing as IV because tpe is 0. The code above does not change tpe so I am not sure why is has ruined your calculation. Can you post what you have in your calculation event?
Views
Replies
Total Likes
This is what it says:
topmostSubform.Page3.tpe::calculate - (FormCalc, client)
sum (rrtotal, programtotal, financetotal, leadershiptotal, executivetotal, meetingstotal, filestotal, brotherhoodtotal, conferencetotal, communicationstotal, minutestotal, standardstotal, basileustotal, abtotal, gramtotal, antigramtotal, tamtotal, pgramtotal, partotal, epistotal, torchtotal, hodtotal, phitotal)
if ($ > 1000 and $ <= 1985)then
level = "I"
elseif ($ > 850 and $ <= 1000)then
level = "II"
elseif ($ > 550 and $ <= 850)then
level = "III"
elseif ($ <= 550)then
level = "IV"
else level = ""
endif
Views
Replies
Total Likes
try putting $ = before your sum:
$ = sum (rrtotal, programtotal, financetotal, lead.....
Views
Replies
Total Likes
That didn't work. It calculates correctly if I remove the IF statement, but not with it. I even tried recreating the cells in a brand new form, but it again only works without the IF. Is it possible for me to send the form to you to look at?
Views
Replies
Total Likes
sure post it online and I will have a look.
Views
Replies
Total Likes
Forgive my ignorance, but I don't see how to do this. How do I upload the file on here?
Views
Replies
Total Likes
Did you forget about me? Still need help. How can i upload the file to you? Thanks.
Views
Replies
Total Likes
You can upload your file on acrobat.com
Views
Replies
Total Likes
Wow, never knew about acrobat.com. Here's the link. The cells in question are on page 3 titled "TOTAL POINTS EARNED" and "CHAPTER LEVEL ATTAINED." "tpe should show the total points earned and "level" should show the level based on the points in tpe. Thanks so much for the help you've given. Sorry to be a pest.
https://files.acrobat.com/a/preview/ef14186f-7ba4-4033-ae5f-e37f6563d43a
Views
Replies
Total Likes
Just put the script into the calculate field of level instead:
if (tpe > 1000 and tpe <= 1985) then
$ = "I"
elseif (tpe > 850 and tpe <= 1000) then
$ = "II"
elseif (tpe > 550 and tpe <= 850) then
$ = "III"
elseif (tpe <= 550) then
$ = "IV"
else $ = ""
endif
Also just having a look at your form - for next time you could have saved yourself a whole lot of time in your setup by using tables for all those fields rather than making each one a seperate numeric field.
Views
Replies
Total Likes
Yes!!!! It worked!! Thank you so much for your help! Really appreciate it!.
I have zero experience with LiveCycle, so the form was made in InDesign, then exported as pdf. As I get more familiar with LiveCycle, I will definitely take your advice. Again, thanks a lot.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies