Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Linking subreports Post Reply Post New Topic
Author Message
Shawnlo
Newbie
Newbie


Joined: 24 May 2011
Location: Canada
Online Status: Offline
Posts: 22
Quote Shawnlo Replybullet Topic: Linking subreports
     Posted: 28 Sep 2011 at 4:01am

I was hoping someone could help me with the following issue.

 

I am trying to link to a sub report on multiple fields and user inputted parameters.

 

What I have is 3 Tables a Terms table, a Storedgrades table, and a standardsgrades table.  I have it set so the user can select Terms.YearID using a parameter by the name of ?TheSchooLYear.

 

I am trying to link like the following:

 

?TheSchooLYear (Terms.YeardID Dynamic drop down) --> standardsgrades.yearID

 

And

 

terms.id --> storedgrades.TermID

 

I do not seem to get any data when I link like this.

 

What I am wondering is if I need to add a parameter for users to select terms.id (which seems kind of redundant) or if I can create some sort of formula to link these.

 

Why I need to link this way is the year format is different in each table

 

terms.id looks like 20,21,22 (Could change) etc

terms.YearID looks like 2000,2001,2002 etc

 

The only link to the year is from terms to each table

 

On my main report I have Terms linked terms.yearid to standardsgrades.yearID in my sub reports I do not have the terms table as I do not see a need for it and when I add it I cannot link.

 

As I write this I noticed one thing I will try again and that is adding a second link in my database expert to link storedgrades to my terms table, if I recall I tried this and it crashes crystal reports.

 

Thank you for taking the time to read this  :)

 

IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 03 Oct 2011 at 9:09am
as a plan of attack, I would try linking on 1 field that you know works.
display the fields that you think might work, and compare them to the user input parameter.  It might be that there are empty spaces or the values don't look like you thought they did (i've had that happen too many times)
 
HTH
IP IP Logged
Shawnlo
Newbie
Newbie


Joined: 24 May 2011
Location: Canada
Online Status: Offline
Posts: 22
Quote Shawnlo Replybullet Posted: 05 Oct 2011 at 4:33am

Thank you for the reply, I did figure out a way to make this work however I am now facing the following problem.  In my sub report I would like to do something like the following in the select statement: (When I try this it is very, very slow)

 

if isnull({STOREDGRADES.STUDENTID})
then
{STOREDGRADES.TERMID} = {?Pm-TERMS.ID} and
{STUDENTS.ID} = {?Pm-STUDENTS.ID} and
{STOREDGRADES.COURSE_NUMBER} like "*LA*" and
{STOREDGRADES.STORECODE} = {?Pm-?Storecode}
else
{STOREDGRADES.TERMID} = {?Pm-TERMS.ID} and
{STUDENTS.ID} = {?Pm-STUDENTS.ID} and
{STOREDGRADES.COURSE_NUMBER} like "*LA*" and
{STOREDGRADES.STORECODE} = {?Pm-?Storecode}and
{STANDARDSGRADES.YEARID} = 21

 

The problem I am facing here is one table has to be displayed {STANDARDSGRADES.}  If there is Data in the table.  However I am having trouble getting my head around this as it filters too much.  If I use the following:

 

{STOREDGRADES.TERMID} = {?Pm-TERMS.ID} and
{STUDENTS.ID} = {?Pm-STUDENTS.ID} and
{STOREDGRADES.COURSE_NUMBER} like "*LA*" and
{STOREDGRADES.STORECODE} = {?Pm-?Storecode}and
{STANDARDSGRADES.YEARID} = 21

 

The sub report has the Data I want with the Standardsgardes table but does not display the data from IDS that do not have information in the standards table.  If I try the following formula I get the reverse of above.

 

{STOREDGRADES.TERMID} = {?Pm-TERMS.ID} and
{STUDENTS.ID} = {?Pm-STUDENTS.ID} and
{STOREDGRADES.COURSE_NUMBER} like "*LA*" and
{STOREDGRADES.STORECODE} = {?Pm-?Storecode}

 

This makes sense to me because I am using "AND"

 

I am just having trouble with the logic of getting both to display.

 

 

IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 05 Oct 2011 at 7:39am
it would seem that if you want the ID irrespective of the linking id, that you would remove this constraint, but I have no idea if that is truly what you want.
 
Running subreports can slow a report down tremendously.
 
I prefer to create stored procedures that are very wide and use them create 'subreport' but as far as the data is concerned, is really nothing more than a grouping
 
HTH
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum