[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Printing multiple reports in one spool job using datasets and setting dataset parameters

Posted on 2008-11-11
3
Medium Priority
?
1,033 Views
Last Modified: 2013-11-23
I am trying to print a single report multiple times in one spool job using the code from the related solution "Delphi 7 ::: Rave Report - Several Reports Print in one spool job".  In the related example the programmer is getting data from a query dataset and passing the results to a rave report using report parameters.  
I on the other hand, am trying to set a dataset using parameters and then have the report use the results in a report which uses DataText and DataBand components.  I can get the report to print one at a time, but I get blank pages when running the report using the attached code by calling the TRvSystem components Execute method.
I checked the queries with the parameters set and they do return results with the correct number of rows of data.  As I stated above I have code elsewhere in my program which prints this report once using a seperate TRvProject component.  And it works with no problems.
procedure TPrintSpecDlg.rvsSpecsPrint(Sender: TObject); //TRvSystem.OnPrint
var MyIndex: integer;
    MyFlag: string;
begin
  rvpPrintSpecs.Open; //TRvProject
  if PrintSpecPricesCheckBox.Checked then
    MyFlag:= ''
  else
    MyFlag:= 'X';
  for MyIndex:= 0 to ItemsListBox.Count-1 do
  begin
    if ItemsListBox.Selected[MyIndex] then
    begin
      FAreaID:= (ItemsListBox.Items.Objects[MyIndex] as TItemRow).AreaID;
      FSpecID:= (ItemsListBox.Items.Objects[MyIndex] as TItemRow).ID;
      SetUpPrintQuery(FJobID, FAreaID, FSpecID);
      rvpPrintSpecs.SelectReport('rpSpec', TRUE);
      rvpPrintSpecs.SetParam('Test_Jibberish', MyFlag);
      GetMyOfc.ParamByName('iOfficeID').AsInteger:= FOfficeID;
      PrintMyItems.ParamByName('iJobID').AsInteger:= FJobID;
      PrintMyItems.ParamByName('iAreaID').AsInteger:= FAreaID;
      PrintMyItems.ParamByName('iItemID').AsInteger:= FSpecID;
      PrintMyInstrs.ParamByName('iJobID').AsInteger:= FJobID;
      PrintMyInstrs.ParamByName('iAreaID').AsInteger:= FAreaID;
      PrintMyInstrs.ParamByName('iItemID').AsInteger:= FSpecID;
      rvpPrintSpecs.ExecuteReport('rpSpec'); 
      (Sender as TBaseReport).NewPage;
    end;
  end;
end;
(*******************)
{ The following Code works fine but it only prints one report at a time }
{ I have this code elsewhere in my program in a datamodule }
{ It uses a seperate TRvProject and dataset components}
function TPrintDataModule.PrintSpec(const AOfficeID, AJobID, AreaID,
  ASpecID: integer; const ShowPrices: boolean): boolean;
var MyFlag: string;
begin
  . . . 
  . . . 
  SetUpPrintMyItem(AJobID, AreaID, ASpecID);
  if ShowPrices then
    MyFlag:= ''
  else
    MyFlag:= 'X';
  rvpPrint.Open;  //TRvProject
  try
    rvpPrint.SelectReport('rpSpec', TRUE);
    rvpPrint.SetParam('Test_Jibberish', MyFlag);
    GetMyOfc.ParamByName('iOfficeID').AsInteger:= AOfficeID;
    PrintMyItems.ParamByName('iJobID').AsInteger:= AJobID;
    PrintMyItems.ParamByName('iAreaID').AsInteger:= AreaID;
    PrintMyItems.ParamByName('iItemID').AsInteger:= ASpecID;
    PrintMyInstrs.ParamByName('iJobID').AsInteger:= AJobID;
    PrintMyInstrs.ParamByName('iAreaID').AsInteger:= AreaID;
    PrintMyInstrs.ParamByName('iItemID').AsInteger:= ASpecID;
    rvpPrint.Execute;
  finally
    rvpPrint.Close;
    . . .
  end; //try..finally
end;

Open in new window

0
Comment
Question by:3tpro
2 Comments
 

Author Comment

by:3tpro
ID: 22960997
Anyone ?
0
 
LVL 38

Accepted Solution

by:
Geert Gruwez earned 2000 total points
ID: 23048922
just an idea, execute the report mulitple times ?

function TPrintDataModule.PrintSpec(const AOfficeID, AJobID, AreaID,
  ASpecID: integer; const ShowPrices: boolean; NumberOfCopies: Integer = 1): boolean;
var MyFlag: string;
  n: Integer;
begin
  . . . 
  . . . 
  SetUpPrintMyItem(AJobID, AreaID, ASpecID);
  if ShowPrices then
    MyFlag:= ''
  else
    MyFlag:= 'X';
  rvpPrint.Open;  //TRvProject
  try
    rvpPrint.SelectReport('rpSpec', TRUE);
    rvpPrint.SetParam('Test_Jibberish', MyFlag);
    GetMyOfc.ParamByName('iOfficeID').AsInteger:= AOfficeID;
    PrintMyItems.ParamByName('iJobID').AsInteger:= AJobID;
    PrintMyItems.ParamByName('iAreaID').AsInteger:= AreaID;
    PrintMyItems.ParamByName('iItemID').AsInteger:= ASpecID;
    PrintMyInstrs.ParamByName('iJobID').AsInteger:= AJobID;
    PrintMyInstrs.ParamByName('iAreaID').AsInteger:= AreaID;
    PrintMyInstrs.ParamByName('iItemID').AsInteger:= ASpecID;
    for n := 1 to NumberOfCopies do 
      rvpPrint.Execute;
  finally
    rvpPrint.Close;
    . . .
  end; //try..finally
end;

Open in new window

0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Loops Section Overview
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month19 days, 4 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question