Solved

Editing Subreport SQL Query at Runtime

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

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…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…

726 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