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!

Sharing date formula from subreport to main report

Status
Not open for further replies.

confused64

Technical User
Nov 10, 2010
8
CA
I'm using crystal reports XI and am trying to share a date formula (@expiry) in the subreport, with the main report. Being a new user, can someone please tell me what the formulas would be and where to place them in the reports? Thanks in advance.
 
I do not know that you can 'share' a formula between a subreport and the main report. The best you can do is either have the formula in the sub-report and the main report (which I have done countless times) or share a variable value (output from the formula?).
 
Currently the subreport (4 of them actually) is in the details line of the main report. This seems to make generation of the report very slow, which is why i was hoping to share instead. Each subreport is generating an expiry date based on courses people take. If there is no way of sharing, is there a better way to do this to speed things up? Here's a simple view of what it currently looks like:


course1 course2 course 3 course4
employee subrep 1 subrep2 subrep3 subrep4
 
Of course any subreport in the details section is cause a serious slowdown. Four subreports in the details is not going to help.

Not sure why you need an subreport for each course (but then again I do not know the data structure). You can pass values from the main report to a subreport and back, not sure if this would help in this situation.
 
I don't think sharing the formula will make the report any faster. It looks like you should rethink your design. Why do you feel you need to use subreports?

-LB
 
as i do not know your report logic, would it be possible to have all 4 of the values in a single subreport then share the values as variables?
IF you must have a subreport this would at least less the run time by only having 1 subreport to compile instead of 4.

Please explain the logic and design of your report a little more, and i think you will get better assistance.
 
ok i'll try to explain it a little better. Each of the four subreports pulls a "completed" date from the same access database table based on 4 separate courses (also in same table). The subreports then calculate a course expiry date based on a validity period and display that date - and this makes things very slow. When i try to do it without subreports, the employee names in left column repeat many times (might be because of formula: if {CoursesAttended.Code}="450011" then {CoursesAttended.DateActioned}+{tbl_Qualifications.Validity}). Like i said before, really new at this, so really appreciate all the help! (Crystal Reports courses scheduled for end March! lol)
 
it sounds like it would be possible to use a single subreport with a shared variable for each course that would then display in your main report, or may just be able to display the subreport values, depending on your situation.

If you need to use shared variables, they may look something like this in the subreport:
//{@sharedCourse1}
whileprintingrecords;
shared stringvar c1;
IF {table.course}="1" then c1 := {table.datedone}
else c1 := "";

And like this in the main report:
//{@sharedUpCourse1}
whileprintingrecords;
shared stringvar c1;
c1



If you can display all the items in the subreport and don't need to use shared variables, you would still use one formula for each course date, but it is very similar to using variable but a bit simpler in the end:
//{@sharedCourse1d}
whileprintingrecords;
IF {table.course}="1" then {table.datedone}
else "";
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top