Link to home
Start Free TrialLog in
Avatar of QTony

asked on

Crystal XI: Filter a user parameter basedon a condition?

I have a subreport that is occasionally  needed; about once a week. When it is not needed, it is suppressed by a condition and does not display.

I would like to add a simple number parameter to this subreport that will allow the user to increase the final quantity that this report produces. (This report generates a list of wood panels)

I was able to create and install the parameter and it does work correctly. However, the parameter prompts for values   everytime the main report runs regardless of whether or not the subreport is supressed..

No matter what conditions I put prior to the parameter formula, I cannot get it to filter out when it is not needed. I know my filters are correct, because if I test them on any other formulas, they work fine. It is only on the parameter formula that they don't apply. I'm assuming I'm doing something incorrect and not understanding  how the parameter field processes.

Here is my parameter and the conditions I am trying to use with it:

If {@PL_GR_CLU_CALC 2} = 0 Then

"QTY: " & ToText({@PL_GR_0.25_CNC_CALC 2} ,0) Else

"QTY: " & ToText({@PL_GR_0.25_CNC_CALC 2} + {?My Parameter},0)

The above formula will still process ?MyParameter even if the the value is "0"

Thank you for looking
Avatar of vasto
Flag of United States of America image

The parameter prompt is shown before the report to start any calculation. It doesn't matter if the subreport os supressed.
Avatar of QTony


That being the case, do you know if it is possible to do some kind of record = null check via sql or some other method? You don't need to explain how, I'm just curious if it is something that is possible and within the scope of a basic user such as myself.

What is the logic behind this parameter? Is it dependent from another parameter ?
Avatar of QTony


Thank you for replying

No, it is not dependent from another parameter; per my original question above, it is only to allow the user to increment up a value. What the report does is total up wood panels that are generated by a cabinet making program All the totals are accurate, but when a total is a certain size,  the operator will often want to add a couple of additional panels to the total for errors, wastage etc.

The problem is that there are a total of 32 different panel types---many of which run infrequently---so if each panel type had a parameter to allow adjustment of the total, the user would end up with 32 parameters on a screen each time the program ran.

Typically, only 2-4 panels display during any given run so if it were possible, I would prefer that only those parameters that apply during the current run display.
What version of Crystal?

You could default all the parameters to 0 and the user would have to provide values for only those needed fo the given run.

You can easily control the prompts by writing your own parameter screen as part of a viewing application.

One of the 3rd-party Crystal Reports UFLs (User Functiobn Library) listed at adds an InputBox() function to Crystal.  
This allows your subreport to create a formula that checks for a value and then prompts the user for some input only if a condition is met.  You can also create such a UFL yourself.
I can see 2 possible ways to handle this:
 1.  Create a UFL library which will receive all calculated totals and show a dialog box to change them.

Here are 2 links how to this:
 2. Implement a logic which will increment the number of panels inside the report. For example if the number of panels is between 0 and 10 add 0, if it is between 11 and 15 add 1 panel  .... You may add a parameter in the main report which will set the template so for the case 10-15 panels you will add 1 additional panel if the user selects template 1 or  add 3 additional panels if the user selects template 2. You can print both values: calculated and additional, which will help you to adjust the logic.

I would prefer the second method because once the logic is set this will be a normal report - you will be able to run it from any application , schedule it etc.
UFL will show a dialog box during the report rendering which will stop the process and will require additional user interaction ( scheduling will be not possible). If the report is running in a background thread this will crash the system because the message box will mess with the UI thread. If you are showing a question for each total this might be a problem too in case the increment for total 1 is somehow related to total 3.
Avatar of QTony


Thank you fall or the tips

Regarding my version, I am currently using Crystal XI...

Learning to create UFLs sounds really attractive to me but I think that for now, I will go ahead and take mlmcc's advice and create a targeted parameter screen with defaults set to 0. One question to mlmcc: When you say, "write your own parameter screen" are you referring to the default screen that is launched by Crystal when creating a ?Parameter field or or you referring to a separate mechanism to create a customised screen that differes in appearance from the default Crystal screen.

Thanks again
Avatar of Mike McCracken
Mike McCracken

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of QTony


Thank you, much appreciated...