Good morning,
unfortunately my initial approach for using a formula to identify the section the formula is iused in, was not possible with built-in methods (https://answers.sap.com/questions/13931185/possible-to-use-if-with-referal-to-eg-details-b.html).
I now have a new approach but I seem to be getting one detail wrong.
Idea is to have a global stringvar as identifier in each section that changes value with section change. And then use this stringvar in a formula within that section.
//formula a
global stringvar section:="a"
//formula b
stringvar section:="b"
//formula test
stringvar section;
local numbervar test;
If section="a" Then
test:=1
Else If section="b" Then
test:=2;
test
However, the stringvar section is being shown correctly in each section but the result of test is always the same (that for the second section.


Does anybody see what I am doing wrong? Are formulas being executed even if they have not been used yet, i.e. global variable is declared before the formula is even being used?
Thank you
Alex
Request clarification before answering.
Try adding "WhilePrintingRecords;" to the top of your formula.
-Dell
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm trying to think around this. Also, looking at your formulas - try taking "Global" off the declaration of section in Formula A. If you're going to us a modifier on a variable, you have to use the same modifier the first time you use the variable in any formula. Otherwise Crystal might think you have two different variables.
For testing purposes, try this:
1. Create another formula that will give you the value of section at any point in time:
{@CurrentSection}
StringVar section;
section2. Instead of using @a and @b in your report as above, use {@CurrentSection}.
-Dell
| User | Count |
|---|---|
| 5 | |
| 5 | |
| 4 | |
| 4 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.