CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Hybrid View

  1. #1
    Join Date
    Feb 2000
    Location
    TX, USA
    Posts
    8

    Crystal Reports - Subreport SQL

    I have a Crystal Report that I access from a VB program and I send an SQL statement to the main report, but I also want to send the subreport a different SQL statement to execute.

    Do I need to pass it a parameter? Or how would I code it in VB to execute inside the subreport?

    Please help! Thanks!


  2. #2
    Join Date
    Feb 2000
    Location
    Ireland
    Posts
    808

    Re: Crystal Reports - Subreport SQL

    Use the SubreportToChange property of the crystal OCX.
    Pass it the name of your subreport and then pass your new selection formula.
    If you creeated the subreport from within a crystal report then when passing the name leave off the ".rpt". If on the other hand your subreport was an existing crystal report then give it its full extension


  3. #3
    Join Date
    Feb 2000
    Location
    TX, USA
    Posts
    8

    Re: Crystal Reports - Subreport SQL

    Do you have an example of how to pass the new SQL to the Subreport?


  4. #4
    Join Date
    Feb 2000
    Location
    Ireland
    Posts
    808

    Re: Crystal Reports - Subreport SQL

    That depends.
    I use crystal reports 7 and I use build my reports from an SQL Query.
    I use the Selectionformula propety of the Crystal OCX to pass criteria to my reports.

    With Crystal1
    .ReportFileName = Trim$(GReportLocation) & "config6.RPT"
    .SelectionFormula = "{Query.acrft_unique_identifier}=" & Val(cmbUniqueID)
    .Destination = 0
    .WindowState = crptMaximized
    .Connect = "DSN=CMS;uid=sa"
    .SubreportToChange = "MyFirstSubReport"
    .SelectionFormula ="Whatever"
    .SubreportToChange = "mySecondSubreport"
    .SelectionFormula ="WHATEVER"
    .action=1
    End With





Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured