Topic: first met value Posted: 16 Jun 2008 at 1:35pm
Hi Guys,
I would be very grateful if you help me solve the following problem. I want to return only the first met value ot a range of values. In the "details section" -> "selection expert"
I've tried with the following
{tbl_Material.Name} in ["value1", "value2", "value3"]
but it compares each record with any of these values and for e.g. returns 3 results not just 1.
Next I've tried same code using a flag value, which should be raised when one condition is met and not letting the other conditions to be compared.
if (({tbl_Material.Name} = "value1") and (flag = 0)) then (flag := 1; {tbl_Material.Name} = "value1") else if (({tbl_Material.Name} = "value2") and (flag = 0)) then (flag := 1; {tbl_Material.Name} = "value2") else if (({tbl_Material.Name} = "value3") and (flag = 0)) then (flag := 1; {tbl_Material.Name} = "value3")
but when I define the flag in the "record selection" for each record it gets zeroed and I get the same result. May be the flag sould be defined somewhere globaly but can't figure out where and how can it be made visible for the "record selection" in this code fragment. Glad to here other suggestions.
Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Posted: 16 Jun 2008 at 1:53pm
Well, you're not showing us your full code b/c I don't see where you are declaring the flag variable. It would have been helpful to see a complete code listing.
I would declare it as Global and don't initialize it to zero. Just do the tests. This will keep it from getting reset every time.
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
This is the full code I declare the flag variable in record selection, but it gets zeroed each time. numberVar flag := 0; if (({tbl_Material.Name} = "value1") and (flag = 0)) then (flag := 1; {tbl_Material.Name} = "value1") else if (({tbl_Material.Name} = "value2") and (flag = 0)) then (flag := 1; {tbl_Material.Name} = "value2") else if (({tbl_Material.Name} = "value3") and (flag = 0)) then (flag := 1; {tbl_Material.Name} = "value3")
Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Posted: 16 Jun 2008 at 2:46pm
Yes, get rid of the ":=0" part. Declare it as Global and don't initialize it.
Global NumberVar flag;
Try that and let me know how it goes.
Edited by BrianBischof - 16 Jun 2008 at 2:46pm
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
the code is not working . I've put global numbervar flag ; on the top of record section but I'm getting all the values again. It seems that the flag gets zeroed for each record.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum