Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Wildcards surrounding parameter Post Reply Post New Topic
Author Message
blueharmony
Newbie
Newbie


Joined: 25 May 2007
Online Status: Offline
Posts: 1
Quote blueharmony Replybullet Topic: Wildcards surrounding parameter
    Posted: 25 May 2007 at 9:24am
Hi,

I have a parameter, {?Title},  that allows users to enter in a title when running the report. I want to make it so the user can enter in any part of the title, and the select statement will pull out any title that contains the text the user entered.  I tried editing the formula in the select expert to be:
  • {tablename.TITLE} like {?Title} -- this doesn't return any results unless the user manually enters wildcards (i.e. *) around their text. For example, if they want to see all titles with the word Coach, they have to enter in   *Coach*. Just entering Coach doesn't pull out any records.

    or

  • {tablename.TITLE} like "*" +{?Title} +"*"  -- this returns all titles in the database.
The documentation says that I should be able to use wildcards and parameters, but I can't find any examples of cases similar to what I'm trying to do.

Thanks,

Marc
IP IP Logged
EscApe
Newbie
Newbie


Joined: 13 Nov 2006
Location: Finland
Online Status: Offline
Posts: 37
Quote EscApe Replybullet Posted: 28 May 2007 at 11:43am
I am not quite sure, what you want to do, if user doesn't enter wild cards to parameter. Here is a solution that will allow user to enter Title-parameter with asterisk or as a full text.

How about testing the parameter for example like this:

if instr({?Title},"*")>0
then {tablename.TITLE} like {?Title}
else {tablename.TITLE} = {?Title}

This will return:
- all titles with Title-text, if user entered *Title*
- only Title-text from D/B, if user entered Title

Instr is used to test, if ?Title has asterisks and if it does, like operator will be used.
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 28 May 2007 at 12:33pm

Try creating a formula that will add the wildcards and then use that in your select expert.  It would look something like this:

{@TitleParam}

"'*" + {?Title} + "*'"

Notice the extra set of single quotes - one before the first asterisk and one after the second.  I think this may be where your problem is.

-Dell

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