Print Page | Close Window

Shared Array variable

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=9687
Printed Date: 28 Apr 2024 at 9:05pm


Topic: Shared Array variable
Posted By: CUser
Subject: Shared Array variable
Date Posted: 14 Apr 2010 at 7:14am
Hi,
 
I am alway little poor in the Array usage. I have Shared String Array variable in Sub Report which I would like to Pass to the Main report. Can someone please help?
 
Thanks,
CUser


-------------
CUser



Replies:
Posted By: lockwelle
Date Posted: 15 Apr 2010 at 3:17am
if you have already declared it as shared array in the subreport, after populating it, use the same declaration in the main report ... after the subreport has been run and the values are available for use.
 
HTH


Posted By: CUser
Date Posted: 15 Apr 2010 at 4:34am
Thanks for the response. I have following code in subreport
 
WhilePrintingRecords;
shared stringvar Array labelquest;
numbervar i:=1;
Redim labelquest[3];
if  condition 1 then
     labelquest[1] := 'condition'
else if condition 2 then
      labelquest[2] := 'condition'
else if condition 3 then
      labelquest[3] := 'condition';
For i := 1 to 3 Do
(
   labelquest = labelquest
);
labelquest[1] + ' ' + labelquest[2] + ' ' + labelquest[3]
 
I don't think I have written above syntax in most correct manner (suggestion are always welcome)
 
It display the database value in subreport and I have following code in my main report after the subreport
 
WhilePrintingRecords;
shared stringvar Array labelquest;
ReDim labelquest[3];
labelquest[1] + ','+ labelquest[2] + ','+labelquest[3]
 
and I am not getting any value in the main report..
 
Help me what am I doing wrong..


-------------
CUser


Posted By: lockwelle
Date Posted: 15 Apr 2010 at 8:26am
when you redim, you erase the array.  You don't need to redim it in the main report, just access the members of the array.
 
HTH


Posted By: CUser
Date Posted: 15 Apr 2010 at 8:52am
Thanks again..
 
I realized the redim keywork so my code now reads
 
WhilePrintingRecords;
shared stringvar Array labelquest;
labelquest[1] + ','+ labelquest[2] + ','+ labelquest[3]
 
My first two label values getting overwritten by the third label, so I am getting same label three times. and if I try to make it as drilldown I get the 'subscript must be between 1 and the size of the array.'
 
Sorry to bother.. but I am totally lost.


-------------
CUser


Posted By: lockwelle
Date Posted: 15 Apr 2010 at 9:31am
For i := 1 to 3 Do
(
   labelquest = labelquest
);
 
I don't think that this code is needed at all.  You have already assigned the value, and you aren't assigning as the syntax for that would be :=.
 
and you probably want to break this into 3 if statements, as only 1 gets a value:
if  condition 1 then
     labelquest[1] := 'condition'
else if condition 2 then
      labelquest[2] := 'condition'
else if condition 3 then
      labelquest[3] := 'condition';
 
HTH



Print Page | Close Window