Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Report Design
Message Icon Topic: Select Expert help on search Post Reply Post New Topic
Author Message
Yume
Newbie
Newbie
Avatar

Joined: 29 Nov 2007
Location: United Kingdom
Online Status: Offline
Posts: 11
Quote Yume Replybullet Topic: Select Expert help on search
    Posted: 09 Jan 2008 at 3:08am
Hello,
 
I'm not sure if this is possible but is there a way to create a parameter that would enable users to enter characters that is contain in a string field.
 
I have a string field that users need to search by but may not know all the characters. The records can be any length and no set pattern, hence they want to search by entering some of the characters to bring out a list of records.
 
Is there a way to create this type of search in the parameter like in the Excel with 'Contains in' function?
IP IP Logged
Lugh
Senior Member
Senior Member
Avatar

Joined: 14 Nov 2007
Online Status: Offline
Posts: 377
Quote Lugh Replybullet Posted: 09 Jan 2008 at 4:34am
Absolutely.  There are actually a few functions that will do this, with varying degrees of precision and with varying options.  Check out String Functions in the help file (or, even better, in Brian's book) for a list of the options.

One of the handy things about Crystal is that it treats a string as an array of characters.  So, in addition to the built-in string functions, you can also use any array functions on it.  This can allow you to perform some really wacky operations, should you really need it (like parsing out address information from untrained user input).


IP IP Logged
Yume
Newbie
Newbie
Avatar

Joined: 29 Nov 2007
Location: United Kingdom
Online Status: Offline
Posts: 11
Quote Yume Replybullet Posted: 11 Jan 2008 at 3:44am
I took a look at the help file and try the filter option but I can't get it to work. The field I'm trying to obtain information from is maximum 25 characters and the records can be from 1 to 25 characters in that field.
 
So far I created a parameter and attached it to that field in Select Expert using the function 'to like'.
 
I'm waiting for my book to be available in Amazon at the moment as they don't have stock Cry
 
My boss wants allow the user to enter a few digits like '1234 etc' and then it brings up records that contains those characters such as 1df24vfg3 for example.
IP IP Logged
Lugh
Senior Member
Senior Member
Avatar

Joined: 14 Nov 2007
Online Status: Offline
Posts: 377
Quote Lugh Replybullet Posted: 11 Jan 2008 at 4:55am
Oh ho!  Now that's a tricky little problem.

OK, first of all, if you enter "1234," do you want 2uy4gty3u1 returned?  I.e., does order matter?  What about 1112233344? 

If order does matter, and duplicates don't, then you can still use "LIKE."  You just need to put an asterisk between each character, e.g. LIKE "*1*2*3*4*".

If order doesn't matter, this gets trickier.  Let me know if that's the case.  Normally, I would check that by simply looping through the string.  But, I'm not sure you can put a loop structure in your selection criteria.  Of course, if the entry is always the same length, or at least has a guaranteed maximum length, then you can do it brute force style, without a loop.  Well, in this case, I guess 25 is certainly the maximum, but that's going to be a nasty long brute force query.

If duplicates do matter, then it gets really tricky.  Especially if you allow duplicates in the search string, and the result has to have the same number of duplicates.  E.g., if you enter 1122, it will return 1*1*2*2, but not 1*1*1*2*2 or 1*2*2.  The easiest way I could see to do that would be with nested loops.  But, again, I'm not sure that's allowed.


IP IP Logged
Yume
Newbie
Newbie
Avatar

Joined: 29 Nov 2007
Location: United Kingdom
Online Status: Offline
Posts: 11
Quote Yume Replybullet Posted: 11 Jan 2008 at 6:08am

Spoke about it to my colleagues and reckons the first suggestion will be satisfactory. Thank you for the big help, never knew how much you can do on CR. Only had two lessons on this.

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.031 seconds.