How to read first or last or nth data record

edited 8:35AM in FastReport 4.0
Hi,
I've been using FastReport with reasonable success for several months now. Generally speaking, I use the band/s to run through a sequence of data as fetched by an SQL function and display data as expected. However I now have a requirement where I need to read data from a specific row of data from the records returned by the SQL function. How do I go about doing that, either in the memo field or in the script.

To better understand what I am trying to achieve, I will explain what I am doing. We have a Delphi program where users enter a data/time range and the report is then generated for that date range. As the data we are extracting is time series data, there is a date/time stamp in the data itself, and I wish to read the first and last dates/times and then display a memo field that states something like "START 1 Jan 2017 END 5 Feb 2017".

I know enough to write the script that generates text in the relevant memo field, but have no idea how to access the required data that has been imported into fastreport by the SQL query. The data is contained in <frxDB1."seqtime">. Note too that this is in the PageHeader field, so this band is currently not linked to the Masterdata, though the band below it is, and the data is available and present (working in the rest of the report). I'm only stating the obvious here to avoid confusion or responses where people may think I'm looking at an "empty" report with no data in it [img]style_emoticons/<#EMO_DIR#>/rolleyes.gif" style="vertical-align:middle" emoid=":rolleyes:" border="0" alt="rolleyes.gif" /> Your help is appreciated, thanks.[/img]

Comments

  • gordkgordk St.Catherines On. Canada.
    edited 8:35AM
    in reports onstaet report event movedataset to first record store field value in a variable move dataset to last
    store field value in another variable then move dataset back to first record
  • edited 8:35AM
    gordk wrote: »
    in reports onstaet report event movedataset to first record store field value in a variable move dataset to last
    store field value in another variable then move dataset back to first record

    Sorry, but what is onstaet, and where do I find it. Is this something I set as script code (as a variable) or elsewhere?

    Another thought, is can I determine which record FastReport is presently processing (when generating a report)? For example, I know I can use <Line> to determine the line number presently being worked on in a report, but could I write some script that looks something like:

    if <Record> = 1 then DateVar = <frxDB."date">; // for first date record

    or

    if <Record> = <Record.Count> then DateVar = <frxDB."date">; // For last date record
  • gpigpi
    edited June 2017
    var StartValue, EndValue: Variant;
    
    procedure frxReport1OnStartReport(Sender: TfrxComponent);
    var DS: TfrxDataSet;                                                              
    begin
      DS:=Report.GetDataset('Items');
      DS.Open;
      DS.First;
      StartValue := DS.Value('Part Name');
      repeat DS.Next
      until DS.Eof;
      EndValue := DS.Value('Part Name');      
    end;
    

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.