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
<< Prev Page  of 2
Author Message
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 21 Dec 2010 at 6:54am
I believe you have your param set to allow for multiple values, therefore the {?Region} is an array
IP IP Logged
blazeme182
Groupie
Groupie
Avatar

Joined: 15 Dec 2009
Online Status: Offline
Posts: 44
Quote blazeme182 Replybullet Posted: 21 Dec 2010 at 8:11am
That is true. I did not think about that. Is there a way arround this allowing multiple values.
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 9:17am
One idea, though quite inefficient, would be to run a loop through each of the values and checking whether the record contains one of them. But once you start specifying many many values and you have many many records it really slows down...

But I'd rather think of alternatives ways to accomplishing what you want to do.

At first I was under the impression that you want to allow users to type in whatever characters and get the relevant records, but that doesn't seem to be the case.

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.


You have a list of cities that you want them to select (as opposed to typing in say "h" and getting all the records whose city name contains the word "h").

I have a report that allows users to select multiple names and output a report showing a list of transactions performed by those users.

I used a record selection formula "{my_field} = {?my_param}" and it only displayed the records whose name corresponds to one of the names on the list.

Edited by Keikoku - 21 Dec 2010 at 9:18am
IP IP Logged
blazeme182
Groupie
Groupie
Avatar

Joined: 15 Dec 2009
Online Status: Offline
Posts: 44
Quote blazeme182 Replybullet Posted: 21 Dec 2010 at 10:42am
A good example of why i am trying to acomplish is in my database {my_feild} will contain a record like Montreal, West
 Island. Now if My Parameter feild is West Island I will only get the feilds that only contain West Island and not the one that contain both Montreal and West Island.
 
To simplify it i need  a formula basicly stating:
 
{my_feild} contains {?my_param}
IP IP Logged
Keikoku
Senior Member
Senior Member


Joined: 01 Dec 2010
Online Status: Offline
Posts: 386
Quote Keikoku Replybullet Posted: 22 Dec 2010 at 3:04am
Perhaps instead of using a static parameter you could instead opt for a dynamic one?

Since you are querying the DB for the ones that match your selection, might as well just let the user pick a bunch of options that he wants to see from a dynamically generated list and just return the records whose city field is one of the ones selected.

That way you won't have to worry about concatenation! :)

But I am still looking for a way to write the "contains" logic without using loops.

Edited by Keikoku - 22 Dec 2010 at 3:06am
IP IP Logged
blazeme182
Groupie
Groupie
Avatar

Joined: 15 Dec 2009
Online Status: Offline
Posts: 44
Quote blazeme182 Replybullet Posted: 27 Dec 2010 at 7:10am
Is there a way to maybe do something like FIND  {?my_param} in {my_feild} and then use an IIF to somhow plug it in?
IP IP Logged
Keikoku
Senior Member
Senior Member


Joined: 01 Dec 2010
Online Status: Offline
Posts: 386
Quote Keikoku Replybullet Posted: 29 Dec 2010 at 3:10am
I think the biggest problem here is the fact that the parameter is an array.

The string function InStr(a, b) returns True if b is a substring of a

Which is what you want! But not for an array

To deal with the array you will have to find ways to either iterate over each element at a time, or see if there's a different function that will handle arrays.

I think it's easiest to just loop over the array for every record, but that may reduce the performance very much.

Edited by Keikoku - 29 Dec 2010 at 3:30am
IP IP Logged
<< Prev Page  of 2
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.