?
Solved

Passing value from Hidden subreport in Header to Main report

Posted on 2005-03-02
5
Medium Priority
?
368 Views
Last Modified: 2012-08-13
Hey all, I am having a little trouble passing a value from a subreport to the main report.  I have a subreport inserted in the header and trying to pass a value from this subreport to the detail section of the main report.  I have the formulas setup and the whole thing works great when I have the header visable.  When I change it to dont show....well then it doesnt work.  I am NOT suppressing the header section!!!!  I am just trying to run this report that passes a few different values to the main report.  

I figured I would run this report in the header....(the users dont need to see it) and then pass it over to the main report where I need this information to show.

Any ideas or help would be greatly appreciated.

Thanks,
Bob
0
Comment
Question by:vmrfadmin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 101

Accepted Solution

by:
mlmcc earned 2000 total points
ID: 13446231
Try this.

Create a second header
Open the report
Click FORMAT --> FORMAT SECTION
Select the header with the subreport
Click INSERT SECTION BELOW
Move the subreport to the new section and make it very small and set it to NOT GROW
Make the new header section also short and set it ot NOT GROW

mlmcc
0
 
LVL 26

Expert Comment

by:Kurt Reinhardt
ID: 13447259
If you're attempting to return a distinct value at the detail level, you may be better served using a SQL Expression field.  A SQL Expression is basically a subquery.  It doesn't have to be data that's related to the main portion of the report.  What version of Crystal are you using and what is your DB?

~Kurt
0
 

Author Comment

by:vmrfadmin
ID: 13451648
Ok guys...thanks for your feedback.

I used your method mlmcc and it works.  I like the fact that it works and am very thankful for your suggestion.  It does seem weird to do it that way.  I am a little confused why you cant hide a header (NOT Suppress) and get the subreport to run and pass the data to the main detail section of the report.  If I ever have to go back and look at my code.....I will have to remember that I have these really small subreports in a header that I have to look at!

Kurt, I like your method but the data from the subreport comes from a different unrelated database than the data in the main report.  I have to run the subreport above the detail section of the report and then pass it as a distinct value to the detailed section of the report.  I am running cr 9 and I am talking to an SQL database and 2 access databases.  

Thanks guys for your comments.  I really appreciate them!  
bob
0
 
LVL 26

Expert Comment

by:Kurt Reinhardt
ID: 13453049
The point of a SQL Expression/subquery is that it can pull in completely unrelated data.  It's also much more efficient than a subreport, because it's processed on the database.  A subreport at the detail level is very inefficient, because it will run once for every detail record.  If there's 50k detail records, the subreport will run 50k times.

Here's a sample of a simple SQL Expression:
//%SampleSQLExpression
(
SELECT DISTINCT
  table.field
FROM
  database.tableb
WHERE
  condition
)

When you review the SQL in the Crystal Report (Database|Show SQL Query), you'll see that the SQL Expression gets added to the SELECT clause as a subquery field:

SELECT
  tablea.field,
  tablea.field2,
  (
  SELECT DISTINCT
    table.field
  FROM
    database.tableb
  WHERE
    condition
  ) AS "SampleSQLExpression"
FROM
  database.tablea
WHERE
  conditions...

In this example, most of the fields come from Table A, but the subquery field comes from Table B, which is unrelated.  There is no correlation between these two tables, but you are able to bring back a distinct field from Table B in every detail record.

~Kurt
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 13454673
Glad i could help

mlmcc
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question