Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: tables in subreport Post Reply Post New Topic
Author Message
Just
Newbie
Newbie


Joined: 21 Feb 2012
Online Status: Offline
Posts: 18
Quote Just Replybullet Topic: tables in subreport
     Posted: 20 Mar 2012 at 12:41am
I have an issue with some sort of connection that exists between subreport data tables and main report data tables.
I have a report with tables A and B and a subreport with tables B and C
I have linked the subreport via a field that is common in both places from table B. table B is a relations table having id of fields in A and C that relates these two together. Data in A can be connected to a related document with data in table C or standalone.

Anyway when I have data that is in table A and not related to any other document (has relation info in table B but no id relation to table C) it does not show me the row dataset. As if the document from rowset from table A cannot exist in the report if it is not related through B to document in table C.

Can someone tell me please how are these 3 tables connected if they are split to main and subreport.Confused I am loosing my mind trying to figure this out.

IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 20 Mar 2012 at 4:05am

in the main report youa re only using tables A and B, correct?

Linking to the subreport to table C would have no impact on the main report. 
I would deconstruct the report looking at things that can impact the data set.
to verify that the sub report is not the culprit, run the report and verify that your expected data set in the main report is missing some rows. unlink or suppress the subreport (suppressed sub reports do not run) and check to see if your missing data appears. It should still be missing.
This should eliminate the sub report as the issue.
othe likely culprits are in the main report as
table joins,
select statements,
suppression formulas


Edited by DBlank - 20 Mar 2012 at 4:06am
IP IP Logged
Just
Newbie
Newbie


Joined: 21 Feb 2012
Online Status: Offline
Posts: 18
Quote Just Replybullet Posted: 21 Mar 2012 at 1:52am
You are a genious. It was not the subreport but linking of tables in the main report. One of two broken reports fixed, thanks to you. Now I have only one left to fix. Tongue
The other one has the same basic idea with parameter passed to subreport to bound date ranges, but I also have to make a selection statement on all 3 subreports. This time I have tables A, B ,C, D in main and B in subreport 1, C in subreport 2, D in subreport 3. I ma creating a date range in select conditions, but it restricts too much, even though I put or between range conditions for each table.So that if even in 1 subreport there is data that meets conditions in that subreport and main report then data is shown.

If you have any ideas on this one you will become my idol.Wink


Edited by Just - 21 Mar 2012 at 1:53am
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 21 Mar 2012 at 3:47am
not sure I am following this set up.
Can you tell me what is the select statement in one sub report and what is the issue with it? Missing data? Too much data? Both?
IP IP Logged
Just
Newbie
Newbie


Joined: 21 Feb 2012
Online Status: Offline
Posts: 18
Quote Just Replybullet Posted: 21 Mar 2012 at 5:10am
Sorry I made it too confusing.
I have split 3 tables into 3 subreports. Every subreport has a selection saying field x ( different field in each subreport) has to be in date range y-z. each element of 'or' below is a copy of selection in a subreport.
In the main report  I have got all tables linked that are in the subreports. the selection in the main report is a copy of all 3 from subreports.
if ({SrsZlecenia.SrZ_DataRealizacji} in DateTime ({?DataOd}) to DateTime ({?DataDo})or
{VatNag.VaN_DataOpe} in DateTime ({?DataOd}) to DateTime ({?DataDo}) or
{TraNag.TrN_DataDok} in DateTime ({?DataOd}) to DateTime ({?DataDo}))
then true

if the selection is true I want the field from a particular subreport that relates to the table from the 'if' sekection to show data from subreport. It restricts too much and I don't know why. it shows data if selection is met in more than one subreport.There is an extra table in main report I group the results by.

If I leave a selection in the subreports only it shows a bunch of data I group by but no data from subreports. I don't know how else to describe it. I can only provide you with my report if my description is not enough.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 21 Mar 2012 at 5:20am
selecting records in a sub report have no impact on the records selected in the main report.
when you link a sub report to the main report it can filter the sub report based on the link. This will appear as part of the a select statement in the subreport using a parameter which is created via the link process.
I am confused as to why youare using subreports at all here. If you have all the tables in the main report then all of the data is available for use there, so the sub reports seem duplicative?
Can you show some sample data and what you want the report to llok like?
IP IP Logged
Just
Newbie
Newbie


Joined: 21 Feb 2012
Online Status: Offline
Posts: 18
Quote Just Replybullet Posted: 21 Mar 2012 at 10:37pm
I gues you are right. however for some reason when all data and tables were in main report instead of 10 lines of data I got only one. I have linked all tables with outer join but it shows only id of dataset that meets all conditons from all tables I have plased in select expert.

When I have moved some tables to subreports from main report to get rid of that problem. But then I  got hundred's of empty rows as result, even though these 3 date conditions have been insterted into subreports. I gues I must have linked the subreports incorrectly.

I have tried to provide you with a sample but pasted it doesn't look right.
I think I may be doing sth wrong with parameter linking. In main report there are two date parameters I have linked with appropriate date field in tables from subreport. But doing just this resulted in a lot of blank lines and wrong data displayed. Only when I have added tables from sub to main rep. (like you said duplicated them) it started showing more less what it should, but still too little.


IP IP Logged
Just
Newbie
Newbie


Joined: 21 Feb 2012
Online Status: Offline
Posts: 18
Quote Just Replybullet Posted: 23 Mar 2012 at 2:06am
I started digging deeper in the subreports and I have found the maistake where you suggested.

So officially now you are my idol. ;)
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