cancel
Showing results for 
Search instead for 
Did you mean: 

Passing Parameter to SubReport

Former Member
0 Kudos

Hi

Im trying to pass a parameter to a subreport however it hasnt got a field to link directly link to


I thought about creating a StringVar for it as -

whileprintingrecords;

stringvar SortBy;

SortBy := {?SortBy};

However as the value could contain multiple values Im getting an error -

This array must be subscripted. For example: Array [i].

Any ideas how to get round my problem ?

Accepted Solutions (1)

Accepted Solutions (1)

abhilash_kumar
Active Contributor
0 Kudos

Hi Allan,

You can create a comma delimited string and pass this to the Subreport as a parameter:

stringvar SortBy;

SortBy := Join({?SortBy},',');

What do you wish to do with this unlinked field though?

-Abhilash

Former Member
0 Kudos

Hi

It passes -

RESORT

PACKAGE

GRADE

PROMOTION

VACATION DATE

SEASON CODE

BOOKING SOURCE

which is then used in a formula that is used for grouping.

So if I use your above code as a formula in the main report and create a corresponding formula in the sub report -

WhilePrintingRecords;

stringvar SortBy;

what is the best way to set up the subreport links ?

Former Member
0 Kudos

Hi

Ive got a bit further

Using the

stringvar SortBy;

SortBy := Join({?SortBy},',');


I have tried to link @SortByVar  = {?SortBy}

However this is now giving me error -

This formula cannot be used because it must be elevated later.

abhilash_kumar
Active Contributor
0 Kudos

Do you wish to setup a group off of this delimited string in the subreport?

-Abhilash

Former Member
0 Kudos

Hi

I havent written this report so Im not completely sure what its doing.

The formula that is using it is being used as a group -

[@GroupByParameters]

stringvar sortString;

sortString:='';

if {@SuppressGraphic}=true

then

(

  numbervar counter:=1;

  numbervar positionCount:=count({?SortBy});

  stringvar ShipCode=' ';

  stringvar Package=' ';

  stringvar Grade=' ';

  stringvar VacationDate=' ';

  stringvar SeasonCode=' ';

  stringvar Promotion=' ';

  stringvar BookingSource=' ';

  if not isNull({Vx_Command.SHIP_CODE})

  then ShipCode:={Vx_Command.SHIP_CODE};

 

  if not isNull({Vx_Command.GROUP_BY_PACKAGE})

  then Package:=ToText({Vx_Command.GROUP_BY_PACKAGE},0,'');

 

  if not isNull({Vx_Command.GROUP_BY_CABIN_CAT})

  then Grade:={Vx_Command.GROUP_BY_CABIN_CAT};

  if not isNull({Vx_Command.SAIL_DATE_FROM})

then VacationDate:=ToText({Vx_Command.SAIL_DATE_FROM},'ddMMyyyy');

 

if not isNull({Vx_Command.SEASON_CODE})

then SeasonCode:={Vx_Command.SEASON_CODE};

 

if not isNull({Vx_Command.IS_PROMO})

then Promotion:={Vx_Command.IS_PROMO};

if not isNull({Vx_Command.SOURCE_CODE})

then BookingSource:={Vx_Command.SOURCE_CODE};

  while positionCount >= counter do

  (

   if trim({?SortBy}[counter])='RESORT' then sortString:=sortString + '_' + ShipCode; 

   if trim({?SortBy}[counter])='PACKAGE' then sortString:=sortString + '_' + Package;

   if trim({?SortBy}[counter])='GRADE' then sortString:=sortString + '_' + Grade;

   if trim({?SortBy}[counter])='VACATION DATE' then sortString:=sortString + '_' + VacationDate;

   if trim({?SortBy}[counter])='SEASON CODE' then sortString:=sortString + '_' + SeasonCode;

   if trim({?SortBy}[counter])='PROMOTION' then sortString:=sortString + '_' + Promotion;

   if trim({?SortBy}[counter])='BOOKING SOURCE' then sortString:=sortString + '_' + BookingSource;

   counter:=counter +1;

  );

sortString;

)

else sortString:='A';

sortString;

abhilash_kumar
Active Contributor
0 Kudos

This formula simply returns a concatenated string based on each element of the SortBy prompt and a few other database fields.

I'm not too sure if it makes too much sense to group off of such a 'static' formula.

-Abhilash

Former Member
0 Kudos

Have you got some time to take a quick look at it if I email you over my reports?

Might be easier to see what its doing that way.

abhilash_kumar
Active Contributor
0 Kudos

Yes, you may e-mail it to me.

-Abhilash

Former Member
0 Kudos

Thanks Abhilash, email is on its way.

Former Member
0 Kudos

Sorted it!

Didnt need the parameter as you suggested and I needed to add the schema location to the subreport to solve my 409 error.

Thanks for you help as always Abhilash

Answers (0)