0
votes

I have a subreport that will search a table pulling all matches depending on two things. 1.) Some filtering criteria in the command for the subreport and 2.)it will search based on the criteria pulled by a parameter from the main report.

1.) Is this possible? I have tried for a few days now to get this to work but I feel I am missing something. I cannot get the field in the main report to pass the information to the parameter for the command in the subreport.

Here is the command for the subreport.....

DECLARE @DIE VARCHAR (20)
SET @DIE = '1315240018'

SELECT DISTINCT BCKUPDIE.TOOL1

FROM FS11HD AS BCKUPDIE

JOIN FS11HD AS ORGDIE 
    ON 
    BCKUPDIE.DIE_SHAPE = ORGDIE.DIE_SHAPE
    AND BCKUPDIE.AROUND1 = ORGDIE.AROUND1
    AND BCKUPDIE.ACROSS1 = ORGDIE.ACROSS1
    WHERE ORGDIE.TOOL1 = @DIE

When run in sql it will give me any TOOL1 rows that have matching criteria. This is what I want my subreport to, am I going about this the wrong way?

2
did you try linking the subreport by the parameter on the main report?cojimarmiami
Yes that was one of my first tries but I ran into several issues doing that..... How am I suppesed to "SET" the declared variable as a parameter coming from the main report? More importantly what is the syntax? Secondly, when i got rid of the declare and just used where, I was unable to assign the variable to that command statementMatthew Jakachira
Lastly, when I try to change subreport links my declare @die never shows up so that I can link that with my dies field from the main reportMatthew Jakachira

2 Answers

0
votes

We have an old version of Crystal report (XI) but the logic might be the same with your version.

On the menu select [Edit] [Subreport Links].

Select the sub report from the pick list then map your select choices to the sub reports selection criteria.

On the sub report you will have to have parameter fields that will match the values up with the values you wish to pass. Such as if you select date as a selection criteria on the main report and you want the sub report to also filter by this date create a date pram in the sub report. By linking all the select criteria with [linked] values it will behave as a straight through pass of the parameters without a prompt box being all have been answered via the linkage between documents.

0
votes

I feel you took difficult path to achive your requirement, Try below solution I hope this will be easy to implement.

Firstly remove the @Die from command instead pass the @Die value from main report as part of formula field.

your subreport query will be changed to

SELECT DISTINCT BCKUPDIE.TOOL1

FROM FS11HD AS BCKUPDIE

JOIN FS11HD AS ORGDIE 
    ON 
    BCKUPDIE.DIE_SHAPE = ORGDIE.DIE_SHAPE
    AND BCKUPDIE.AROUND1 = ORGDIE.AROUND1
    AND BCKUPDIE.ACROSS1 = ORGDIE.ACROSS1

In main report create a formula @Die and enter data as '1315240018'.

Now link main report and sub report and in linking pass the @Die formula and your main report parameter to sub report, By this you have these as parameters in sub report.

In record selection of sub report write as below.

ORGDIE.TOOL1 = ?Die //value passed from main report
and your parameter linking

By this your filtering criteria will be added to the sub report query.

This should work let me know incase any error