Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: filtering records using " Post Reply Post New Topic
Author Message
maciaso
Newbie
Newbie
Avatar

Joined: 20 Mar 2008
Location: United States
Online Status: Offline
Posts: 11
Quote maciaso Replybullet Topic: filtering records using "
     Posted: 20 Mar 2008 at 11:28am
I am trying to write a formula in Crystal 10 that only returns records where a value/word is found in the field searched. 
Any ideas on how to create this formula?  
 
thanks
OM
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 20 Mar 2008 at 1:37pm
not IsNull({table.field}) or ({table.field} <> '')
 
-Dell
IP IP Logged
maciaso
Newbie
Newbie
Avatar

Joined: 20 Mar 2008
Location: United States
Online Status: Offline
Posts: 11
Quote maciaso Replybullet Posted: 21 Mar 2008 at 4:28am
Thank you.  I guess I was not that clear since your answer is to provide all record but the ones that are null.
 
Now, within the records I get I need only those that contain the word "rail" within the results.  thnx
OM
IP IP Logged
saoco77
Senior Member
Senior Member


Joined: 26 Jun 2007
Online Status: Offline
Posts: 104
Quote saoco77 Replybullet Posted: 21 Mar 2008 at 5:25am
To accomplish this I think you'll need to create a parameter.

And then in the selection formula set

{table.field}={?parameter}

This will allow you to subset the fields based on the input value.

Hope this helps.

Sarah
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 21 Mar 2008 at 10:27am
If you're looking to find if a string is part of a larger string (a substring), then use the Like operator with a wildcard. For example, your record selection formula would be:
{table.field} LIKE "*"&{?parameter}&"*"

You can learn lots of tips and tricks for working with parameters in my Crystal Reports eBooks.
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
maciaso
Newbie
Newbie
Avatar

Joined: 20 Mar 2008
Location: United States
Online Status: Offline
Posts: 11
Quote maciaso Replybullet Posted: 21 Mar 2008 at 10:31am

The wild card was the way to go.  Thank you

OM
IP IP Logged
Angelflower
Newbie
Newbie
Avatar

Joined: 11 Sep 2008
Location: United States
Online Status: Offline
Posts: 3
Quote Angelflower Replybullet Posted: 11 Sep 2008 at 10:37am
I am trying to use the LIKE "*"&{?parameter}&"*" statement in my crystal report but it doesn't seem to work, but when I copy the code out of crystal report and run it in SQL it works.
 
This is the line of code in crystal: {provider.fullname} like {?ProviderName} & "*"
This is how the line of code translate in SQL: provider."fullname" LIKE 'adams%'
 
What am I doing wrong in crystal?
 
Thank you in advance for your help.
Live well...Be happy
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 11 Sep 2008 at 11:29am
Is your database case sensitive?  You can test this by entering looking at the data and then entering the parameter in the same format as the data.  For example, if the value in the provider.fullname field is in the format "Adams..." then enter your parameter as "Adams" instead of "adams".  If that works, then your database is case sensitive.  In that case, you'll need to manually update your selection formula to something like:
 
upper({provider.fullname}) like upper({?ProviderName}) & "*"
 
-Dell
IP IP Logged
Angelflower
Newbie
Newbie
Avatar

Joined: 11 Sep 2008
Location: United States
Online Status: Offline
Posts: 3
Quote Angelflower Replybullet Posted: 11 Sep 2008 at 12:30pm
Hi Hilfy,
 
Thanks for the reply. I just got it working using this:
 
{provider.fullname} like TrimRight ({?ProviderName}) &"*"
Live well...Be happy
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