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!

Selection parameter using a shared variable

Status
Not open for further replies.

BradCustom

IS-IT--Management
Oct 5, 2007
296
US
I'm using Crystal 2008 and I have a question on if a shared variable can be used in either a record selection or group selection.

The report is structured as follows:
The main report has two tables, Jobs and Customers
The subreport has two tables, Job Operation and Job Operation Time

The main and subreport are linked by the job field.
The subreport has many records for each job so I've created the following formula so that only the maximum work date is shown.
Code:
 Maximum ({Job_Operation_Time.Work_Date})

This value is then passed to the main report using the following formula
Code:
 whileprintingrecords;
shared dateTimeVar maxwork := Maximum ({Job_Operation_Time.Work_Date})

On the main report I'd like to limit the selection to records who's maximum work date falls between "date X" and "date y".

I tried creating a parameter on both the main an subreport but the Maximum Work Date formula and the Pass formula are not available.

Any help with this issue would be appreicated.
 
You can't use shared variables in selection formulas. I'm wondering whether you would be better off bringing those tables directly into the main report in order to limit records instead of using a subreport. Why did you choose the subreport approach?

If you need the sub, I think you would have to place it in a job group header_a section, and then pass the variable in order to suppress unwanted records. This wouldn't be very efficient--you basically have unwanted records in the sub that you are not displaying and also would have unwanted jobs in the main report that are suppressing from view.

-LB
 
I didn't think I could use a variable in a selection formula but I thought I'd ask.

The reason I used a subreport is because each Job has multiple operations and each operation has multiple time entries. I'm using the subreport to obtain the last time entry.

I tryed creating the report without a subreport but I had to many repeating records becuase of the multiple operations.

What I'm trying to display is all the Jobs that have a "complete" status with a maximum work day that falls within a date range.

Hope that helps.
 
So the sub shows the last time entry and only the one corresponding operation instead of multiple operations per job?

-LB
 
Yes, that's correct. Actually I only show the last time entry because I'm trying to show the number of days it takes to complete a job. Based on the datediff between the order date (which is in the job table)and the maximum work_date (which is in the Job_Operation_Time table).

I'm trying a new report without the subreport, by placing the fields I need in the footer. I'll let you know how it goes with this approach.

Thanks for your help!
 
Ok, I was over thinking this report. I eliminated the subreport and placed the 4 tables in the same report.

All I needed to do is place the work date field in the G2F (Job) and the report returns the maximum date for that Job. I then moved all the other fields and formulas I need for this report into G2F. Everything is working fine and I can create the parameter field on Job_Operation_Time.Work_Date to limit the selection to Jobs who's maximum work date falls between "date X" and "date Y".

Thanks for your help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top