Link to home
Start Free TrialLog in
Avatar of Michael Graham
Michael GrahamFlag for United States of America

asked on

Crystal Reports 11 Multiple Parameters on same field

Hello,

I have a field in which my boss wants two separate parameter prompts on the same field (I have always used a range parameter).

The two prompts would be 1.) |enter first number| and 2.) |enter last number|

The field is just a number (it can only be 2 through 5).  

If |enter first number| = 2 then |enter last number| would give a choice of 2, 3, 4, or 5.  If they enter 5  for|enter last number|then you would get values 2, 3, 4, and 5 in the report.  If they enter 3 for |enter last number| then they would get values 2 and 3 in the report.

However, if |enter first number| = 3 then |enter last number| could be 3-5

If |enter first number| = 4 then |enter last number| could be 4-5

If |enter first number| = 5 then |enter last number| could only be 5

I'd also like a dropdown option and an ALL in the dropdown for both parameters which would just return all results.

If this is possible at all I would really appreciate the help.  I'm pretty new to this but I bet this would be pretty tricky.

Thank you,

Mike
Avatar of Mike McCracken
Mike McCracken

I don't believe what you want can be done in Crystal.  You could do it in your own application and parameter page.

mlmcc
It may not matter, but, just in case, are you talking about CR XI or CR 2011?

 Is it really necessary to have the choices for the second parameter be based on the value selected for the first parameter?  If they make bad selections (eg. 5 and 2), they just won't get any data.  If you wanted, you could put a message on the report that appears when the selected range is invalid.

 If you really want to limit the second parameter, I was thinking that you might be able to use cascading parameters to base the values in the second parameter on the values in the first one, but I haven't used cascading parameters, so I don't know if that will actually work.

 If the parameters are numeric, you can't have an "All" value, but you could use something like 0 to designate "all".  FWIW, if you selected 0 for the first parameter, you would still have to select a value for the second parameter, unless you made the second parameter optional (if your version of CR supports that feature).

 If you made the parameters string, you could have an "All" value, but then you'd have to convert the strings to numbers to compare with your field.  Converting the values is not a problem, especially if the parameters are limited to specific values ("2", "3", "4", "5" or "All"), as long as the conversion step doesn't prevent the test on your field from being sent to the server (so that it can filter the records for you).  FWIW, if the second parameter is a string and has a default value, then the user won't be required to select a value for that parameter (that seems to apply to string parameters, but not numbers).  IOW, if they select "All" for the first parameter, they can skip the second one.

 James
Avatar of Michael Graham

ASKER

Hi James,

Thanks for the response.  I am using Crystal Reports 11.  

I still have a lot of work to do on this report (and this is basically my first report).

1.) I need to format an 11 digit field that looks like this presently: 11111111111.  I need to make it look like 11111-1111-11

2.) The parameters I am using worked for what I was trying to accomplish above (for example if they enter 4 for the first parameter and they enter 2 for the second parameter the report is blank which is what I want).

3.) I am trying to figure out how if they leave a parameter field blank it will just return all records.

4.) In my Report Header I used imported an OLE Object (PDF) and my boss was wondering if there was some way to do this natively in Crystal to make it look better.
FWIW, I saw your other question about this after I posted my reply.

 For #3, it depends on what you mean by "leave a parameter field blank".  If it's a string field, you can have the empty string as the default value and you'll get that if you skip that parameter.  If it's a numeric parameter, I think you'll have to select a value, unless the parameter is optional.

 If you can decide on an "all" value for the parameters, it's easy enough to check for that value in the record selection.  For example, if you have 2 numeric parameters and want to get all records when either of them is 0, you could use something like:

{?param1} = 0 or {?param2} = 0 or
({your field} >= {?param1} and {your field} <= {?param2})

 You should start new questions for the other questions, since they're unrelated.

 James
Thanks James,

It is a numeric parameter.  I tried to put the parameter as optional but it is still forcing me to input a value.
I haven't actually used optional parameters, so I don't know why that would happen.  FWIW, if you can get that to work, then you'll need to use HasValue to know when a value was not entered for the parameter.

 James
SOLUTION
Avatar of Mike McCracken
Mike McCracken

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks again.  I am not sure where to put these formulas.

Anyways, my boss wants me to write the OLE object manually so that is something I understand how to do it is just gonna be time consuming
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial