Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: first met value Post Reply Post New Topic
Author Message
steelmanot
Newbie
Newbie


Joined: 16 Jun 2008
Location: Bulgaria
Online Status: Offline
Posts: 3
Quote steelmanot Replybullet 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.

Edited by steelmanot - 16 Jun 2008 at 1:36pm
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet 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>
IP IP Logged
steelmanot
Newbie
Newbie


Joined: 16 Jun 2008
Location: Bulgaria
Online Status: Offline
Posts: 3
Quote steelmanot Replybullet Posted: 16 Jun 2008 at 2:36pm
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")

IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet 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>
IP IP Logged
steelmanot
Newbie
Newbie


Joined: 16 Jun 2008
Location: Bulgaria
Online Status: Offline
Posts: 3
Quote steelmanot Replybullet Posted: 17 Jun 2008 at 2:25am
Hi Brian
the code is not working Confused . 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.
IP IP Logged
Printable version Printable version

Forum Jump
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