[TotalPages] is 0 if user cancelled after Show()

I have this in the report's footer text:
footerText.Text = "[Page] / [TotalPages]";

This works normally fine, but if after the report.Show() the user cancels, this will be displayed as 1 / 0, 2 / 0 etc.

I found this in the manual that may indicate why:
"int Total
The number of total pages in a report. This parameter may be 0 when
preparing a report, because the number of total pages is unknown."

Is there still a way to have this number show correctly even if cancelled?

Comments

  • edited 6:18PM
    i tried to cancel single-pass report, it showed total pages only 35 (out of 100 pages), not zero as you said.

    have you tried cancelling double-pass report?
  • edited 6:18PM
    It is 0 for me in both cases (it is Double-Pass normally).

    6AQW6c6.png
  • gordkgordk St.Catherines On. Canada.
    edited 6:18PM
    I DON;T WORK WITH .NET
    but i would expect you are cancelling before you are in the second pass.

    mod this code
    footerText.Text = "[Page] / [TotalPages]";
    delphi e xample
    if engine.finalpass then footerText.Text = "[Page] / [TotalPages]";
    flse footertext.text ="nan"

  • edited 6:18PM
    Seems logical.

    I decided to do this then, if anybody is interested.

    Rpt.Prepare();
    if (!Rpt.Aborted)
    Rpt.ShowPrepared(true,this);

    Thanks for the help.
  • edited February 2017
    i forgot to explain why, in my case, total pages didnt show zero, i used "Page [Page#] of [TotalPages#]", note: there is additional #, use built-in progress window and single-pass report

    from documentation:

    TotalPages#
    Total number of pages in the report. If you join several prepared reports
    into one package, this variable will return the number of pages in a
    package. You don't need to use double pass to get the correct value.
    This variable is actually a macro. It value is substituted when the
    component is viewed in the preview window. That means you cannot use
    it in an expression.

    Page#
    Current page number. If you join several prepared reports into one
    package, this variable will return current page number in a package.
    This variable is actually a macro. It value is substituted when the
    component is viewed in the preview window. That means you cannot use
    it in an expression.

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.