Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Report Design
Message Icon Topic: using 'Like' in Record selection formula issue 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: using 'Like' in Record selection formula issue
    Posted: 10 Sep 2009 at 6:18pm
Hi All,
 
I have used 'like' in Report -> Selection Formula -> Record:
{HEADING_sub.HEAD} like {?subjects}
 
In the parameter prompt I gave instructions to user by typing
*Search Term*. ( with both * at the begining and the end of the Term). But the user doesn't like typing '*', they awlays want to type search term directly.
However typing * or not  typing * will return quite different set of records.
With * , there are more hits than without *.
Could anyone advise how to integrate * in the {HEADING_sub.HEAD} like {?subjects} above without typing * at the parameter prompt?
thanks in advance.
 
John
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 10 Sep 2009 at 7:32pm
Not at work so can't test this but I think
{HEADING_sub.HEAD} like ('*'+{?subjects}+'*')
should work
or you can just use an instring function
instr({HEADING_sub.HEAD},{?subjects},1)>0
IP IP Logged
johnwsun
Senior Member
Senior Member


Joined: 28 May 2008
Location: Australia
Online Status: Offline
Posts: 179
Quote johnwsun Replybullet Posted: 10 Sep 2009 at 7:57pm
Hi DBlank,
 
the first option result in CR returning everything! I don't think it's searching the 'Term' typed in the parameter prompt.
the second option has an error "The array must be subscripted, e.g. Array"
Please advise again, thank you.
John


Edited by johnwsun - 10 Sep 2009 at 7:58pm
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 11 Sep 2009 at 7:01am
You have the param set to allow multiple values?
That messes both of these up...
 
It gets into arrays which is not my forte but take a look at this...might help
 
IP IP Logged
johnwsun
Senior Member
Senior Member


Joined: 28 May 2008
Location: Australia
Online Status: Offline
Posts: 179
Quote johnwsun Replybullet Posted: 11 Sep 2009 at 11:24pm
Hi DBlank,
 
No, it does not take multiple values; it only allows to search a term at a time as instructed to the user, e.g. *nursing* in my original approach, tt results returns well but the user doesn't like to type *.
 
John
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 12 Sep 2009 at 8:48am
Hey John,
I would double check that setting in the parameter.
I tested both processes and they both worked fine for me if the parmater was set with "Allow mutliple values"=False. When I changed that value to True both failed in the exact same way you described. The * process returned all not null records and the instr() choked on the array subscript.
If it is set to False, what are the other properties set to? Since my test of either approach worked I would think it would have to do with param properties being different than my test param.


Edited by DBlank - 12 Sep 2009 at 8:50am
IP IP Logged
johnwsun
Senior Member
Senior Member


Joined: 28 May 2008
Location: Australia
Online Status: Offline
Posts: 179
Quote johnwsun Replybullet Posted: 12 Sep 2009 at 11:39pm
Hi DBlank,
 
thank you very much for pointing out...I was acutally doing 'allow multiple values ' but I gave up, and forgot to set that back to false. Yes, after using the first option you have advised, it works now.
However I will have to go back to check  the user's specification whether it requires multiple values or not. But searching multiple terms in differnt subject areas would not make sense in this report. For exmaple, searching 'nursing' only want to find nursing related information. When searching 'nursing' and 'engineering' would not make sense. If they require multiple values even in one subject area, I think I will refer to the example in the link you advised earlier.  Thank you very much for your help.
John
IP IP Logged
johnwsun
Senior Member
Senior Member


Joined: 28 May 2008
Location: Australia
Online Status: Offline
Posts: 179
Quote johnwsun Replybullet Posted: 22 Sep 2009 at 5:15pm
Hi DBlank,
 
The user has to enter *term* in the parameter popup box, I'm afraid,  after I have tried to use CR's join function without sucess.:
{HEADING_sub.HEAD} = join({?subjects},  ', ' )
(without entering '*' with the searching terms.)
tthe formula  from the link above you advised works the same way as the join function except adding some filtering(I don't need to filter searching terms).
The searching must allow multiple terms so I will keep the setting as True for Allow multiple values.
IP IP Logged
zach18
Groupie
Groupie
Avatar

Joined: 08 Feb 2011
Online Status: Offline
Posts: 46
Quote zach18 Replybullet Posted: 15 Dec 2011 at 11:54am
Originally posted by johnwsun

Hi DBlank,
 

The user has to enter *term* in the parameter popup box, I'm afraid,  after I have tried to use CR's join function without sucess.:


{HEADING_sub.HEAD} = join({?subjects},  ', ' )

(without entering '*' with the searching terms.)

tthe formula  from the link above you advised works the same way as the join function except adding some filtering(I don't need to filter searching terms).

The searching must allow multiple terms so I will keep the setting as True for Allow multiple values.


I just created a formula that took the parameter and appended stars to both sides. then i used that formula in the select expert.

the formula looked like this
'*' + {?Parameter} + '*'

that worked for me.
Using Crystal Report 2008
www.zachtech.us
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.016 seconds.