Results 1 to 6 of 6

Thread: Passing parameters to a sub report ...

  1. #1

    Thread Starter
    Frenzied Member TheBionicOrange's Avatar
    Join Date
    Apr 2001
    Location
    Cardiff, UK
    Posts
    1,818

    Resolved Passing parameters to a sub report ...

    Right I hope I can explain this one properly ...

    I have a report with a sub report in the detail area.
    The records in my sub report need filtering by a date range.
    I have 2 parameters, namely Start Date and End Date.
    These parameters have been created in my main "Design" area.

    Because this main area doesn't access the table whose data I need to filter I am having trouble filtering my records.

    So .... what do I do ?

    As far as I can tell the obvious thing would be to create the 2 parameter fields in the sub report, but then I would have the same problem in reverse, i.e. The main report won't see them.

    Can anyone suggest any possible solutions ?

    Thanks in advance for any help offered.
    Last edited by TheBionicOrange; Mar 16th, 2006 at 06:37 AM.

  2. #2
    Frenzied Member
    Join Date
    Nov 2001
    Location
    Mass USA
    Posts
    1,674

    Re: Passing parameters to a sub report ...

    Here's a link to the post below this... You pretty much just have to link your parameters through the sub routine object.

    http://www.vbforums.com/showthread.php?t=393149

  3. #3

    Thread Starter
    Frenzied Member TheBionicOrange's Avatar
    Join Date
    Apr 2001
    Location
    Cardiff, UK
    Posts
    1,818

    Re: Passing parameters to a sub report ...

    Oh I didn't think of that !
    Well now I can't seem to define how the date will fall between the parameters, but like most problems with CR, keep looking round and you'll find an option somewhere

    Cheers Besoup !

  4. #4
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: Passing parameters to a sub report ...

    Well now I can't seem to define how the date will fall between the parameters
    Once you have setup the links between the Sub-report and the Main report, double click on the Sub-Report object that is on the Main report. This will open the sub-report in design mode. If the Links are setup properly Crystal will create a record selection formula using the parameters. You can modify the formula through the Report -> Edit Selection Formula -> Record menu (in Crystal 8.5).

    Change it to something like

    {TabelName.DateFieldName} >= {?Pm-?StartDate} And
    {TabelName.DateFieldName} <= {?Pm-?EndDate}

    The ?PM-? parameter field names are automatically generated by Crystal.

  5. #5

    Thread Starter
    Frenzied Member TheBionicOrange's Avatar
    Join Date
    Apr 2001
    Location
    Cardiff, UK
    Posts
    1,818

    Re: Passing parameters to a sub report ...

    I'm on version 9 so its slightly different, but basically I can get to "Modify Subreport Links". My problems start when I am actually there !
    I can click over "Start Date" and "End Date" parameter fields to the right, but in the dropdown list labelled "Subreport Parameter Field to Use" all I get is "?Pm- ?Start Date" to choose from.
    The other dropdown box gives me the following options:

    Report Fields


    Database Fields
    ---Condition Details---

    That last one is the table I am using in the subreport.
    Any of the above optins I choose the program basically ignores, and oes back to highlighting the "Report Fields" option.
    Also, if I check the "Select Data in Subreport based on Field" checkbox it then goes and unchecks it.
    There is a field on the Condition Details table called "Date", which is what I am trying to set my parameters round.

    I hope I'm making sense. I can pretty much see what you guys are trying to tell me, which is basically modify the links to the subreport, but I don't have what I need available in these dropdown boxes to successfully do that.

    Do I have to declare 2 local fields in the sub-report, and use those to link to the parameter fields in the main report ?

    Sorry to be a pain, I'm on a steep learning curve with this !

  6. #6

    Thread Starter
    Frenzied Member TheBionicOrange's Avatar
    Join Date
    Apr 2001
    Location
    Cardiff, UK
    Posts
    1,818

    Re: Passing parameters to a sub report ...

    OK I sussed it.
    I didn't realise I could define my date range parameter field in the sub-report. I had it at the top level, which is why I couldn't see it !
    So ... I took it out of there, put it in the sub-report, used it in the "Select Expert", realised that as a cr*p way of looking at things, switched to Formula Editor, sorted it in there using the "in" clause ...... and bingo ))

    This report has taken me 2½ days, but when I started it I knew b*gger all about Crystal Reports. Now I have multiple embedded "on demand" sub reports and parameters governing what comes out.

    Gold star for me ))

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