Solved

Editing Subreport SQL Query at Runtime

Posted on 2002-03-07
3
1,158 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
ID: 6846816
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
ID: 6846824
hi jrmn

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

zerobro
0
 

Expert Comment

by:yas1891
ID: 7377771
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

867 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

24 Experts available now in Live!

Get 1:1 Help Now