Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Searching string with spaces Post Reply Post New Topic
Author Message
mandylyn23
Newbie
Newbie


Joined: 16 Jul 2012
Online Status: Offline
Posts: 6
Quote mandylyn23 Replybullet Topic: Searching string with spaces
     Posted: 16 Jul 2012 at 12:37pm
I have a report that searches a large text field for certain keywords based on a list of reportable events. One of the terms I am looking for is 'ER' as in emergency room. In my Record Selection Formula I have

...
or " ER " in {COMP_PROD_DESC.COMP_PROD_DESC_TXT}
or " ER." in {COMP_PROD_DESC.COMP_PROD_DESC_TXT}
...

among all the other terms. In the results I am getting events back that do not have 'ER' by itself rather -er as part of another word; i.e. customer, determined, etc.

I have tried:
"* ER *"
"*ER*"
"?ER?"

and I still get the same results. From the behavior I am seeing it seems as though the spaces around ER are being trimmed when provided in a string.

Please help! I am on a tight deadline with updating this report and another similar one. We do not want these to show up in the report as events. I also tried using SQL syntax including spaces and wildcard, but CR did not accept it when trying to save. I am using CR 9.

Thanks.
IP IP Logged
z9962
Senior Member
Senior Member
Avatar

Joined: 04 Jul 2012
Online Status: Offline
Posts: 161
Quote z9962 Replybullet Posted: 16 Jul 2012 at 8:58pm
chr(32) = space. not sure if this is the only way to do it, but it works...

chr(32) & "ER" & chr(32) in {COMP_PROD_DESC.COMP_PROD_DESC_TXT}
IP IP Logged
mandylyn23
Newbie
Newbie


Joined: 16 Jul 2012
Online Status: Offline
Posts: 6
Quote mandylyn23 Replybullet Posted: 17 Jul 2012 at 7:00am
z9962, thanks. However, I am still getting the same results. Any other suggestions...?
IP IP Logged
mandylyn23
Newbie
Newbie


Joined: 16 Jul 2012
Online Status: Offline
Posts: 6
Quote mandylyn23 Replybullet Posted: 18 Jul 2012 at 12:06pm
After doing some further testing, I found that spacing is actually respected in literal strings. To solve my issue with the ER example I used UpperCase because Crystal is case sensitive

" ER " in UpperCase({COMP_PROD_DESC.COMP_PROD_DESC_TXT})

To be consistent I updated all my literal strings to uppercase and used UpperCase() before my field name{}.

Through this I also found that neither * nor % can be used as wildcards. They are recognized as literals at least in Crystal 9.
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