Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using wild card '*' in a parameter 3

Status
Not open for further replies.

jbhsuman

Technical User
Nov 11, 2003
68
US
CR 9
I have setup a parameter for filter on a user code. However, on occasion, I need to print the report for all user codes. I tried using the wildcard '*' charater but it does not seem to work. Any suggestions?
 
Use a record selection formula like this...

IF {?UserCodeParam} = "*"
THEN {Table.UserCode} <> {?UserCodeParam}
ELSE {Table.UserCode} = {?UserCodeParam}

 
Did you amend your record selection criteria accordingly?

Like, but not restricted to, :

If {?Parameter} <> '*'
Then {Field} = {?Parameter}
Else True

Naith
 
Thank you both for yousuggestions. I will try it and let you know the results.

TY

Joe
 
For the sake of efficiency, I recommend that you never use a wildcard unless you need to do partial parameter searches. Also, the record selection statements listed above won't be passed to the database for processing. Instead, they'll be processed on the client side after all the records have been returned.

You have a couple of options that will do the same thing in a more efficient manner (force processing to occur on the server):[ol][li]Assuming that {?UserCodeParam} is String datatype, add a default value of 'All'[/li]

[li]Use one of the following statements in your Record Selection Critieria[ul]
[li]Example 1

Code:
({Table.UserCode} = {?UserCodeParam} Or
{?UserCodeParam} = &quot;All&quot;)

The formula above is efficient, but it has constraints. Notice that it is encapsulated in Parentheses. This forces the statement to be evaluated as a whole. This is especially important if you have any other criteria. If you do have additional Criteria then it should be placed before the above statement in order to be passed to the server for evaluation. See the following example:

Code:
{Table.UserState} = 'AZ' And
({Table.UserCode} = {?UserCodeParam} Or
{?UserCodeParam} = &quot;All&quot;)
[/li]

[li]Example 2

Code:
(
  If {?UserCodeParam} <> &quot;All&quot; 
  Then {Table.UserCode} = {?UserCodeParam}
  Else If {?UserCodeParam} = &quot;All&quot;
  Then True
)

The above statement is more verbose, but has fewer limitations. For example, you can place additional criteria before or after the encapsulated statement.[/li][/ul][/li][/ol]If your parameter is Numeric then you can create a parameter such as 999 (or any other numeric code not used in your pick list) to be used as 'All'. Just subsitute 999 for 'All' in any of the statements above.

Additionally, you could set the description of 999 as 'All' and set the Display to 'Description'. If you do this, you'd have to create Descriptions for all other pick list values as well. If you have a very large pick list, this isn't such a good option because the setup and maintenance are very high.

~Kurt


 
Kurt,

Thank you for your help. It worked just fine.
 
If I may ask you all another question off topic. In my previous version of CR 8, I was able to display field information from a table that is not linked to other tables in the report. For example, I have one table that holds the client informaion and does not link to any other table in the database. I want to be able to display the clients name in the report header without hard coding it into the report via a text field.

When I switched to CR 9 I can see the un-linked table, select the field and insert it into the report. However, at print time, the field information is blank. Do you have any idea what I may be doing wrong?
 
I am only running 8.5 at this client site...so I can't test it in 9.

You might be better of starting a NEW THREAD for this topic in the Crystal Decisions: Crystal Reports 2 Data Access forum.
 
MrJ, once again, thank you for responding. I appreciate your effort and advice.

Joe
 
Unlinked tables are not supported by CR - or really any rdbms application.

If you can't link the tables, but need data from both, you should use a subreport or tailored datasource to display the non related information.

Naith
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top