Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: create a checkbox in CR XI Post Reply Post New Topic
Author Message
johnwsun
Senior Member
Senior Member


Joined: 28 May 2008
Location: Australia
Online Status: Offline
Posts: 179
Quote johnwsun Replybullet Topic: create a checkbox in CR XI
     Posted: 26 Oct 2009 at 1:36am
Hi All,
 
I intend to creat a checkbox in Crystal Report XI. what I did was as follows:
 
I creat a formula @check_box where I entered:
if {INS.CODE} in ['XXX', 'YYY', 'ZZZ'] then  // CODE -- string value
  chr(253)   // display a checkbox with a cross
else
  chr(168) // display a checkbox only
 
then I drag the formula into Group header, and right click to select format field, select font tab, and choose Windings as a type of font, and size = 12
 
However the above approach didn't work; if I comment out "if {INS.CODE} in [XXX, YYY, ZZZ]", there is a checkbox with a cross appeared. Of course this is not what I expected to achieve. It looks like the report deosn't recognises the if-then condition.
Could somebody please adivse a workable approach/ Thanks in advance.
John


Edited by johnwsun - 26 Oct 2009 at 1:37am
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 26 Oct 2009 at 5:56am

since it will do what you want, but doesn't like the if statement, I would work on debugging the if statement.

I would create several simple functions, like just printing {ins.code}, then {ins.code} = XXX, maybe, also equal to YYY and see if they are reporting as expected.  Then I would try combining them into an if statement with the in and see if they report as expected.
 
If the formula works for = but not the in, then I would create a local variable and set that for each case and then the if statement would use the local variable.
 
HTH
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 26 Oct 2009 at 7:25am
I agree with Lockwelle's approach here don't forget to deal with NULL values if you have them...
if isnull({INS.CODE}) or NOT ({INS.CODE} in ['XXX', 'YYY', 'ZZZ']) then chr(168)
else chr(253)
 
Note that I have successfully used the same "if then" approach to present checked or unchecked boxes using windings so there is hope Thumbs%20Up
IP IP Logged
johnwsun
Senior Member
Senior Member


Joined: 28 May 2008
Location: Australia
Online Status: Offline
Posts: 179
Quote johnwsun Replybullet Posted: 26 Oct 2009 at 4:35pm

Hi Lockwelle,DBlank,

thanks for the help, the approach above works in my reports!

John

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