Add Records into TfrxUserDataSet

I have a dataset where I am trying to place into the TfrxUserDataSet. I am not sure how to do this.

Here is some of the code.

unit ReportPrinter;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IO_Tools, frxClass;

type
TfrmReport = class(TForm)
ds : TfrxUserDataSet;
frxReport : TfrxReport;
public
procedure ReportSetup;
procedure ScreenPreview;
end;

var
frmReport: TfrmReport;

implementation
uses MainForm;

{$R *.dfm}

(* Get Data from the MainForm to be placed onto the report *)


procedure ReportSetup;
type
//Declare Report Record
TReportRecord = record
Order : string[20];
Tab : string[20];
ReportSection : String[50];
SubSection : String[20];
CommonFieldName : String[50];
CommonLabelName : String[50];
HotFieldName : String[50];
HotLabelName : String[50];
ColdFieldName : String[50];
ColdLabelName : String[50];
end;

var
ReportRecords : array[1..89] of tReportRecord;
begin
//Add Records to TReportRecord
with ReportRecords[1] do
begin
Order := '1.01';
Tab := '';
ReportSection := 'Company';
SubSection := '';
CommonFieldName := 'tester';
CommonLabelName := '';
HotFieldName := '';
HotLabelName := '';
ColdFieldName := '';
ColdLabelName := '';
end;
// (88 more records come after this)

//Fill dataset

// I am not sure how to add these records to the ds dataset

frmReport.ds.RangeEnd := recount;
frmReport.ds.RangeEndCount := 89;

end;

procedure ScreenPreview();
begin
ReportSetup;
frxReport.PreviewOptions.Maximized := false;
frxFinReport.PreviewOptions.Buttons :=[pbPrint, pbPageSetup, pbNavigator];
frxReport.ShowReport;
end;

I don't seem to know how to attach the records that were created in the ReportSetup procedure into the dataset.

Any help would be greatly appreciated.

Eddi Rae

Comments

  • gordkgordk St.Catherines On. Canada.
    edited 10:31PM
    take a look at the masterdetailuds project in the demos folder
  • edited 10:31PM
    So I should have my array as follows ...

    ReportRecords : array[1..89, 1..2, 1..2, 1..2, 1..2, 1..2, 1..2, 1..2, 1..2, 1..2, 1..2] of String = ( ; //Record Number, Order, Tab, ReportSection, SubSection, CommonFieldName, CommonLabelName, HotFieldName, HotLabelName, ColdFieldName, ColdLabelName

    ('01', '1.01','','Company','','tester', '', '', '', '', '')

    all the rest of the records

    )

    Would I have to do the above or could I fill the dataset with the records as I have them defined?

    I am still not seeing how to fill the dataset with ALL of the records in the demo that you said to look at.
  • gpigpi
    edited 10:31PM
    You should use TfrxUserDataset OnFirst, OnNext, OnPrior, OnGetValue, OnCheckEOF events
  • edited 10:31PM
    I am not understanding why this would help. I am only trying to fill the dataset with the array. Would the way that I am defining the array be correct?
  • gpigpi
    edited 10:31PM
    See a demo in the C:\Program Files (x86)\FastReports\FastReport 5\Demos\MasterDetailUDS folder
  • edited 10:31PM
    Those are 2-dimensional arrays on both the Master and the Detail. I have 10 elements for each record that I need to use in the Master. Can you associate a "record" with a Master?
  • gpigpi
    edited 10:31PM
    wrote:
    Can you associate a "record" with a Master?
    Yes, use OnGetValue event
  • edited 10:31PM
    Please elaborate.

    I am not very familiar on coding in Delphi, so just telling me what to use without an example doesn't help me at all.

    I am trying to use what I initially posted and I am not getting any values when I run the report. I am thinking that this is the way to do it, but I don't see how to connect to the report. I do have the Master linked to the dataset. So how do I link the record type into the dataset.

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.