Solved

Editing Subreport SQL Query at Runtime

Posted on 2002-03-07
3
1,164 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying 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

Suggested Solutions

Title # Comments Views Activity
Pictures In Crystal 10 55
Problem with exporting crystal report to PDF through ASP.NET 23 70
Crystal Report Date Range Parameters 2 73
Count If in Crystal Reports 2 18
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…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

792 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