Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: formula not working Post Reply Post New Topic
Author Message
AdamField
Groupie
Groupie


Joined: 04 Jun 2009
Online Status: Offline
Posts: 88
Quote AdamField Replybullet Topic: formula not working
    Posted: 16 Oct 2009 at 3:55am
Hey Guys,
 
Got a formula that is working in the simple form but the moment i expand it, it start's do go wrong
 
This is what i have
 
DB1 Backorkl
:   colums with info im using    b_afwerk (boolean)
                                                 b_relnum
 
DB2  bomatch
:   colums with info i'm using   b_type
                                                b_aantal
 
DB1 and 2 are linked with the relnum field
 
 
when i use formula
IF {backorkl.b_afwerk} = true THEN "NVT"
          ELSE "OK"
it works in my report
when i expand the formula to
 
IF {backorkl.b_afwerk} = true THEN "NVT"
          ELSE IF {bomatch.b_type} = 1 THEN
              IF totext({?aantal}) = totext({bomatch.b_aantal},0,"")
                    THEN "OK"
              ELSE totext({bomatch.b_aantal},0,"")
 
it stops giving me "NVT" values but the second part works (i get or the OK or the bomatch.b_aantal)
 
It looks like the formula ignores the b_afwerk test
the 2 DB's are linked with a inner join if that may help
 
Tnx for the help in advance !!
 
 
 
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 16 Oct 2009 at 6:27am
try:
IF {backorkl.b_afwerk} = true THEN(
 "NVT"
)
ELSE(
 IF {bomatch.b_type} = 1 THEN (
     IF totext({?aantal}) = totext({bomatch.b_aantal},0,"") THEN
      "OK"
        ELSE
         totext({bomatch.b_aantal},0,"")
    )
)
 
it is your statement, just reformated, with the () to group the various sections.  I wouldn't think that it would make a difference, but whenever CR is not doing what I think it should, I try this...as long as the if statements are what I want.  I think that sometimes CR gets confused.
 
HTH
IP IP Logged
AdamField
Groupie
Groupie


Joined: 04 Jun 2009
Online Status: Offline
Posts: 88
Quote AdamField Replybullet Posted: 16 Oct 2009 at 7:01am
Hey Lockwelle,
 
This worked like a charm, tnx big time !!
 
got one additional question on this
i use this formula in a subreport from a main report
to my sub i send 3 fields
cdoknum = a field from backorkl  (i use this to find the correct document in a big list)
cartikelnr = another field from backorkl (to find the correct article on that document)
cdetaant = one from bomatch (this is to compare the amount ordered to the amount in bomatch )
 
the backorkl db is a list of all the backorder's our customers have the bomatch file is a file that lists on backorder line number if that line (article) is already reserved for that customer.
 
the second part i wanted to ask if that sometimes a article is in the main rpt but it's not in the backorkl db file (becouse the customer already removed that order)
for some reason the article keeps poping up on the main rpt (i can change the data source there) but becouse it is on there but not on the bomatch or backorkl the field i full with the formule gives "" as result while i would rather have it show "NVT"
 
any idees on this ?
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 16 Oct 2009 at 8:22am
I am guessing that changing the join to an outer (either left or right depending) will allow the change to show.  You would need to add 'OR isnull({backorkl.b_afwerk})'.  you might try adding the isnull part and see if that works.
 
I would place the {backorkl.b_afwerk} on the report and see what is displayed on the line in question and modify the logic in the if statement to match.
 
HTH
IP IP Logged
AdamField
Groupie
Groupie


Joined: 04 Jun 2009
Online Status: Offline
Posts: 88
Quote AdamField Replybullet Posted: 16 Oct 2009 at 8:32am

super lockwelle

 
will try this out
 
tnx for the fast feed back !!
 
Adam
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 16 Oct 2009 at 9:03am
Just a warning on this...
If you are adding an "ISNULL(field)" condition to an OR statement you may need to make it the first condition in the OR.
I find that often it won't check it as the second part of the condition.
IP IP Logged
AdamField
Groupie
Groupie


Joined: 04 Jun 2009
Online Status: Offline
Posts: 88
Quote AdamField Replybullet Posted: 16 Oct 2009 at 9:40am
made a workarround on the problem by adding one more field to do the check on so i didn't had to use the afwerk field.
 
just by adding 2 fields from the main report to the sub.
 
Tnx for all the feedbacks and tnx for the solution on the first problem.
IP IP Logged
Post Reply Post New Topic
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



This page was generated in 0.031 seconds.