Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing Shared arrays to subreports at group level

Status
Not open for further replies.

phellis

Programmer
May 17, 2000
28
GB
I have set up a dummy subreport at the group footer level of my main report. The idea being that I can build up a shared array and pass it to the subreport.

I'm successfully setting up the array in the main report however when I try to get the data out in the subreport it appears that my array counter isn't incrementing correctly.

I've got a formula in the details section of the subreport

whileprintingrecords;

shared stringvar array GroupNameArray;
numbervar subcounter;

GroupNameArray[subcounter]

And the subcounter is incremented using a seperate formula in the details section of the subreport

whileprintingrecords;
numbervar subcounter;
subcounter:=subcounter + 1

If I put the counter into the first formula the counter goes out of range for the array. As it stands its set to 0.

What am I doing wrong?

 
I've now found a way of using sub reports "without" hitting the database server if the subreport is using the same data as the main report. I'm using v10 to do this.

Basically you populate shared arrays with the data you are interested in showing in the subreport. One array for each field.

To get the subreport to work and include a details section you need to have some sort of database connection however this doesn't have to hit any of the tables. Instead use the Command option and set up a dummy table variable using the following SQL

----------------------------------------------------
--Declare the variables
Declare @Count int
Declare @Dummy table(
Dummy int
)

--initilise the counter
set @Count = 1

--Create a loop to populate the dummy table
while @count <= 999
Begin
Insert @Dummy
Select @Count

set @Count = @Count + 1
end

Select Dummy
from @Dummy

---------------------------------------------------

By placing the Dummy field in the detail section of the subreport the subreport will run and will also act as a counter to pull the data out of the array.

Hopefully this will help others who have slow reports because the subreport hit the database for exactly the same data as the main report.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top