INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Disallow printing of report if no parameters entered... record select formula?

Disallow printing of report if no parameters entered... record select formula?

(OP)
I have a report with a paramater that allows multiple values.

When the user enters no values, then the report prints all data. I am trying to disallow printing if at least one value hasn't been entered in the parameter field.

Can I write a formula in my Record Select? Or would a formula to suppress the detail section work? If so, can you help with the formula?

RE: Disallow printing of report if no parameters entered... record select formula?

Create a new parameter value 'All' then use this in your select.

IF {?Param} <> "(All)" THEN {TABLE.FIELD} = {?Param} ELSE TRUE

If no parameter is entered or selected, the report shouldn't print anything.

Jose

RE: Disallow printing of report if no parameters entered... record select formula?

(OP)
Thanks for that Jose. It works.

I would like to ask how I would alter that to handle a second parameter with this scenario.

So, if both are empty then don't print. If either is empty and the other is not empty, then print.

In other words, don't print only if both parameters are empty.

RE: Disallow printing of report if no parameters entered... record select formula?

Pretty sure it's the same thing basically, just use AND between params in your select. Both would have to evaluate to TRUE for the report to print records. I don't have a report in front of me right now that uses this, but I've used it in the past and it should work. You can use this for as many parameters as you wish to evaluate.

IF {?Param} <> "(All)" THEN {TABLE.FIELD} = {?Param} ELSE TRUE

AND

IF {?Param2} <> "(All)" THEN {TABLE.FIELD} = {?Param2} ELSE TRUE

RE: Disallow printing of report if no parameters entered... record select formula?

(OP)
Hi,

I just tried that and I also was trying some nested IF combinations and they didn't work.

With your suggestion it allows print if first parameter is not empty and second parameter is empty. It does not allow printing if first parameter is empty, but second parameter is not empty. I need that to print.

FYI. My second parameter is numeric, so instead of ALL I am using 999999. Is that correct?

This is what I have, and it doesn't work for second parameter.

IF {?Param} <> "(All)" THEN {TABLE.FIELD} = {?Param} ELSE TRUE

AND

IF {?Param2} <> 999999 THEN {TABLE.FIELD} = {?Param2} ELSE TRUE

RE: Disallow printing of report if no parameters entered... record select formula?

I'll need to look at it more closely when I'm in front of Crystal. In the meantime, hopefully someone can offer a solution. If not, I'll try to get back to you early next week.

RE: Disallow printing of report if no parameters entered... record select formula?

I appears that you are mixing datatypes for the results of your If statement, which is not allowed in Crystal Reports (i.e., if cond then number else number, not if cond then number else boolean).

RE: Disallow printing of report if no parameters entered... record select formula?

(OP)
Hi kray4660,

Can you suggest how I should accomplish my requirement then please?

RE: Disallow printing of report if no parameters entered... record select formula?

Opps I looked at the If statements incorrectly. You are returning Boolean in both cases ( Thought I saw the := assignment statement). Anyhow if you want Crystal to check if a parameter value has been entered. You have to use the HasValue function. Of course it helps if you are using a version of Crystal Reports that allows the use of optional prompts (I do not remember what version that was introduced).

RE: Disallow printing of report if no parameters entered... record select formula?

(OP)
Hi,

I tried the HasValue() function. Although Crystal seems to accept the formula, when I run the report from our ERP system, it errors out.

It seems to always accept the first part of the IF statement, but not the second.

For example if I enter the {?Filter_omlSalesOrderLineID} parameter, then the report runs. But if I blank out the {?Filter_omlSalesOrderLineID} parameter and enter a {?Filter_omlSalesOrderID} parameter it doesn't print anything.

CODE

IF {?Filter_omlSalesOrderLineID} <> 999999 THEN {SalesOrderLines.omlSalesOrderLineID} = {?Filter_omlSalesOrderLineID} ELSE
IF {?Filter_omlSalesOrderID} <> "(All)" THEN {SalesOrderLines.omlSalesOrderID}= {?Filter_omlSalesOrderID} ELSE  TRUE 

If I reverse the above statements, then it will print only if the {?Filter_omlSalesOrderID} is entered.

The logic seems that it should work, but I don't get why it doesn't.

I also tried:

CODE

if {?Filter_omlSalesOrderID}='All' and {?Filter_omlSalesOrderLineID} = 999999 then true else
if {?Filter_omlSalesOrderID} <> 'All' then {SalesOrderLines.omlSalesOrderID} in {?Filter_omlSalesOrderID} else {SalesOrderLines.omlSalesOrderLineID} in {?Filter_omlSalesOrderLineID} 

Anyone have any other ideas?

My main objective is to allow the report to run/print if either of the multi-value parameters are entered. If both are blank, then I don't want the report to print.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close