Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: Looking for a Formula for (X contains Y) Post Reply Post New Topic
Page  of 2 Next >>
Author Message
blazeme182
Groupie
Groupie
Avatar

Joined: 15 Dec 2009
Online Status: Offline
Posts: 44
Quote blazeme182 Replybullet Topic: Looking for a Formula for (X contains Y)
    Posted: 17 Dec 2010 at 8:37am
Im wanting to create a select expert formula that will only show records that contains a certain word.
IP IP Logged
Keikoku
Senior Member
Senior Member


Joined: 01 Dec 2010
Online Status: Offline
Posts: 386
Quote Keikoku Replybullet Posted: 17 Dec 2010 at 9:33am
Try using wildcard matching with the "like" function

ie: if I want to select only the records with the substring "si" I would write


{my_field} like "*si*"


The *'s means a substring of any length of any characters can follow before and after, but the string "si" must be found somewhere in the record itself.


Edited by Keikoku - 17 Dec 2010 at 9:34am
IP IP Logged
blazeme182
Groupie
Groupie
Avatar

Joined: 15 Dec 2009
Online Status: Offline
Posts: 44
Quote blazeme182 Replybullet Posted: 20 Dec 2010 at 5:33am
Yes I thought about doing something like that. I will give it a try. do you think it will work if I am replacing the "*si*" with a parameter field?
IP IP Logged
Keikoku
Senior Member
Senior Member


Joined: 01 Dec 2010
Online Status: Offline
Posts: 386
Quote Keikoku Replybullet Posted: 20 Dec 2010 at 6:17am
Yes, if it is a string.
You will have to use concatenation in that case.


{my_field} like "*" & {?my_param} & "*"


Edited by Keikoku - 20 Dec 2010 at 6:22am
IP IP Logged
blazeme182
Groupie
Groupie
Avatar

Joined: 15 Dec 2009
Online Status: Offline
Posts: 44
Quote blazeme182 Replybullet Posted: 20 Dec 2010 at 6:53am
I get an error this array must be subscripted
IP IP Logged
Keikoku
Senior Member
Senior Member


Joined: 01 Dec 2010
Online Status: Offline
Posts: 386
Quote Keikoku Replybullet Posted: 20 Dec 2010 at 7:37am
Where did the error come from?
I don't know what your code is doing ... maybe you have arrays?
IP IP Logged
blazeme182
Groupie
Groupie
Avatar

Joined: 15 Dec 2009
Online Status: Offline
Posts: 44
Quote blazeme182 Replybullet Posted: 20 Dec 2010 at 11:15am

I don't know it is weird. the parameter field includes a few different cities that were manually entered by me. if the city in the parameter field matches the database field it will query that field.

 

Hope i'm making sense

IP IP Logged
Keikoku
Senior Member
Senior Member


Joined: 01 Dec 2010
Online Status: Offline
Posts: 386
Quote Keikoku Replybullet Posted: 21 Dec 2010 at 2:44am
There probably is some way to narrow down where the error might be.

Is it during run-time? Or perhaps the error-checker is telling you that your formula contains errors?

Could be a typo, or perhaps the data you think you have isn't what you expect.

Only worked with arrays once, so don't know much about it. Maybe you can post the formula?
IP IP Logged
blazeme182
Groupie
Groupie
Avatar

Joined: 15 Dec 2009
Online Status: Offline
Posts: 44
Quote blazeme182 Replybullet Posted: 21 Dec 2010 at 4:32am
My formula is simple:
 
{Properties.user_1} like "*" & {?Region} & "*"
 
the erros is:
 
This array must be subscripted. For example: Array .
IP IP Logged
Keikoku
Senior Member
Senior Member


Joined: 01 Dec 2010
Online Status: Offline
Posts: 386
Quote Keikoku Replybullet Posted: 21 Dec 2010 at 6:35am
I'm surprised they don't actually highlight what they're talking about. What a not-as-useful error-checker :S
IP IP Logged
Page  of 2 Next >>
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.