How to get page numbers from report created in code?

I've created a report in code and it is working just fine. But how do I access the <Page> and <TotalPages> variables so that I can put them in the page footer?

Here is the basics of what I am trying to do which does not print any page numbers (see the .Text property near the bottom):

Thanks,

Dale
procedure TReportsDlg.DoCustomReport1(const zShowAsPreview: boolean);
var
  oReport:          TfrxReport;
  oPage:            TfrxReportPage;
  oReportTitle:     TfrxReportTitle;
  oPageHeader:      TfrxPageHeader;
  oMasterData:      TfrxMasterData;
  oPageFooter:      TfrxPageFooter;
begin
  {--- REPORT ---}
  oReport := TfrxReport.Create(Self);
  oReport.Clear;
  oReport.DataSets.Add(frxMaster);
  oReport.EngineOptions.DoublePass := True;

	{--- PAGE ---}
  oPage := TfrxReportPage.Create(oReport);
  oPage.SetDefaults;
  oPage.Orientation := lclPageOrientation(iOrientation);

		
	{---- report title, page header and databand go here -----}
		
		
  {--- Page Footer ---}
  oPageFooter := TfrxPageFooter.Create(oPage);
  oPageFooter.Height := 30;
  oPageFooter.Width := 720;
    
	{--page footer contents--}
  with TfrxMemoView.Create(oPageFooter) do begin  {Page nums}
    CreateUniqueName;
    Height := 20;
    Text := 'Page ' + oReport.Variables['Page'] + ' of ' + oReport.Variables['TotalPages'];   { <---- how to do this??? }
    Width := 300;
  end;
		
	oReport.ShowReport;
end;

Comments

  • gordkgordk St.Catherines On. Canada.
    edited 7:18PM
    change the memos text to
    Text := 'Page ' + '[Page]' + ' of ' + '[TotalPages]';
  • edited 7:18PM
    PERFECT!

    Thanks,

    Dale


Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.