Solved

Editing Subreport SQL Query at Runtime

Posted on 2002-03-07
3
1,154 Views
Last Modified: 2008-03-04
Hi Guys,

In crystal 8.5, is there a way to edit the subreport's query at runtime? I wanted to edit/modify the WHERE clause of the subreport's SQL query.
Is this thing can be done? If it's possible, can you please show me a Delphi code on how to do this.
I'm using MSSQL 2000.

TIA,
zero

0
Comment
Question by:zerobro
3 Comments
 
LVL 4

Accepted Solution

by:
jrmn earned 100 total points
Comment Utility
Hi zerobro,

You have to first point the Crystal VCL to the particular Subreport and then read/write the SQL Query property:
 
Crpe1.ReportName := 'c:\test.rpt';
Crpe1.Subreports[1];
Crpe1.SQL.Clear;
{Build the Query}
Crpe1.SQL.Query.Add('WHERE DEPT."DEPTNO" = 10');
Crpe1.SQL.Query.Add('ORDER BY DEPT."DNAME" ASC');
{Remember to set the component back to the main Report}
Crpe1.Subreports[0];
Crpe1.Show;
 
If you want to retrieve the Query you have to call the Retrieve method first.  This is one of the only classes in the new Crystal VCL that still retains a "Retrieve" function.  The reason for this is explained in the UCrpe32.hlp (Help) file.

You should just edit the WHERE clause.  Leave the SELECT and FROM as they are in the Report just like in the crystal reports designer.

Goodluck,
jrmn

0
 

Author Comment

by:zerobro
Comment Utility
hi jrmn

Thanks for the help...your suggestion solved my problem.

zerobro
0
 

Expert Comment

by:yas1891
Comment Utility
Hi,
Do you know how i can use runtime data selection in delphi, would you please show me this by Delphi code ?

when i am trying to do this
Crpe1.ReportName:='test.rpt';
Crpe1.Tables[0].DataPointer:=CrpeDs.DataPointer;
Crpe1.Show;

i face to this message Error 553 : PeSetNthTablePrivateInfo ...

Please let me know how i can solve it.
Cheers,
Yas
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

743 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now