Crystal Reports Range Parameter

Hi all,

I have a report (written in Crystal 9) whereby the user enters 2 numerical parameter range values. For example the user enters Value1 = 1 and Value2 = 5.

I then want my report to display 5 details, one for each value between and including the range values. So this would show 5 detail values 1,2,3,4 and 5.

How do I do this?

Thanks in advance
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Does your data actually include records for every value in the range?

 If it does, it should be simple.
 If it does not, you can try to get the report to show something for any missing data.  Whether or not that will work may depend on how complex your report and data are.

 As far as the range goes ...

 Are you actually using a range parameter (a single parameter that allows a range of values), or two separate parameters (one with the minimum value and one with the maximum)?

 If it's a range parameter, you can go to the record selection formula and enter a test like:
{your field} = {?range parameter}

 CR will understand that the parameter is a range and include every value in the range.

 If you have two separate parameters, the test would be something like:
{your field} >= {?start parameter} and {your field} <= {?end parameter}

 I haven't used CR 9, but in CR 10 you can get to the record selection formula by going to Report > Selection Formulas > Record.

FMabeyAuthor Commented:
Hi James,

Thanks for your reply.
I am using a single parameter which I have set to type number and has range value(s) checked. The user is then presented with two boxes 'start of range' and 'end of range'

Unfortunately, none of the values defined in the parameters exist in my data! Essentially, my data will return only one row, a part ID. We print out a set of pre-defined trace numbers (my parameter values). So if we want 5 of these parts, the user will enter the next set of available trace numbers, so that may be 6 to 10 for example.

I then want the detail multiplied 5 times to show the part ID on each detail, along with the next value in the range.


PartID = P16
Range = 6 to 10


PartID: P16
TraceID: 6

PartID: P16
TraceID: 7

PartID: P16
TraceID: 8

PartID: P16
TraceID: 9

PartID: P16
Ah.  So you're basically trying to duplicate the data a certain number of times, based on the range.  It sounds similar to the situation where someone is printing labels and wants to print a varying number of copies of each label, based on a field (like a quantity).

 One way to do that kind of thing is to have a table that just contains a list of numbers, and Join your main table to that, based on some field, so the data is repeated X number of times.  But that may not fit your situation that well, since I don't know if you have a field that could be used to Join the two tables.

  How big could the range be?  If it's not too big, you could create duplicate copies of your detail section, and then suppress the ones that you don't need to see.  For example, if the range will never be larger than 10, create 10 detail sections with your PartID field, and then use section suppression formulas like the following:

 For the second detail section:
{?end of range} - {?start of range} < 1

 For the third detail section:
{?end of range} - {?start of range} < 2

 and so on.

 For the TraceID, you could use a different formula in each section that adds X to {?start of range}.  Add 0 in the formula in the first detail section, 1 in the second, and so on.

 But if the range could be too large, then using multiple copies of the detail section may not be practical/possible.

CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

Another way to do this if you can add a table to the database is to create a table with a column for all potential trace numbers.  You can then include it in the report and select on it.  There is no need to join it to the current data since you really want a cross join.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
FMabeyAuthor Commented:
Thanks for your help guys.

James, you pushed me in the right direction and mlmcc, thanks for the suggestion of an unlinked table... Works a treat.

Thanks, mlmcc.  I thought about a cross-join, but I wasn't sure it would work, and thought it might be really inefficient even if it did.  I've never needed one, so I really didn't know.

 And you're welcome, FMabey.

It could be inefficient but it is probably since the report is probably only getting 1 record it won't be noticed.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Crystal Reports

From novice to tech pro — start learning today.