Splitting up report based on a value

EPMLEPML UK
edited 7:29AM in FastReport 4.0
(Using D7 Ent)

Hi All,

Still learning how to use Fr4 at the moment and was wanting to get some guidance on how I can make a report start a new page when the month changes in the data results I get from the query populating the report.

I have a Date field in the select statement of my query so I can always work out the month and the query is ordered by the Date field too.

At the moment the report continuously displays data from the Master Data block over numerous pages. What I need to do is make sure a month change in the returned data, starts a new page in the report.

Can anyone shed some light on how I can achieve this please.

Many thanks for any help in advance.

Comments

  • Anu de DeusAnu de Deus Hampshire, UK
    edited 7:29AM
    In the report script, in the OnBeforePrint of your MasterData band, check for the field value and call Engine.NewPage;
    something like

    var PreviousMonth : Integer;

    MasterData1.OnbeforePrint;
    begin
    if (<mainquery."month">) <> PreviousMonth then
    Engine.NewPage;
    PreviousMonth := <mainquery."month">;
    end;

    Obviously this is just an (non-working) example, you need to extract the month from your query and store it somehow, I assume you could use integer.
    Maybe you can create a function (if there isn't one already) like ExtractMonthFromDate.
    Another option is to use a GroupHeader object, just fill in all the fields and it will do it for you. Read the User Manual.pdf, it's all there
  • EPMLEPML UK
    edited 7:29AM
    In the report script, in the OnBeforePrint of your MasterData band, check for the field value and call Engine.NewPage;
    something like

    var PreviousMonth : Integer;

    MasterData1.OnbeforePrint;
    begin
    if (<mainquery."month">) <> PreviousMonth then
    Engine.NewPage;
    PreviousMonth := <mainquery."month">;
    end;

    Obviously this is just an (non-working) example, you need to extract the month from your query and store it somehow, I assume you could use integer.
    Maybe you can create a function (if there isn't one already) like ExtractMonthFromDate.
    Another option is to use a GroupHeader object, just fill in all the fields and it will do it for you. Read the User Manual.pdf, it's all there


    Thank you Anu de Deus for your help with this. [img]style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> I will try it out and let you know how I get on![/img]
  • EPMLEPML UK
    edited 7:29AM
    EPML wrote: »
    EPML wrote: »
    In the report script, in the OnBeforePrint of your MasterData band, check for the field value and call Engine.NewPage;
    something like

    var PreviousMonth : Integer;

    MasterData1.OnbeforePrint;
    begin
    if (<mainquery."month">) <> PreviousMonth then
    Engine.NewPage;
    PreviousMonth := <mainquery."month">;
    end;

    Obviously this is just an (non-working) example, you need to extract the month from your query and store it somehow, I assume you could use integer.
    Maybe you can create a function (if there isn't one already) like ExtractMonthFromDate.
    Another option is to use a GroupHeader object, just fill in all the fields and it will do it for you. Read the User Manual.pdf, it's all there


    Thank you Anu de Deus for your help with this. [img]style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> I will try it out and let you know how I get on![/img]

    Just wanted to let you know that your example helped me achieve what I needed! Many thanks again.

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.