Master Detail problem

edited May 2015 in FastReport 4.0
Hi

I have a fairly simple form with just 2 date time pickers on.

I have 2 oracle datasets on my form, the 1st dataset executes and gets me an "Operator" name (Master), which it then passes to the second dataset to bring all the records for that "operator". Now I have created a TfrxDBDataset component for each oracle dataset, and the frxReport1 component.

I have a IF statement in my source code, that if a record is found in dataset1, it must then send the values to dataset2. This form used to be done with RaveReports, so it was quite easy to print each line and then NEXT. Trying to do that with FastReports has not been so successful.

I create a new report which has a header inherited from a base report, I create a Master Band and a Detail band, and assign dataset1 and dataset2 respectively.

The problem I am having is that it prints the Master fine, but then it reprints the detail for the 1st record for every single master and never moves on?

Below is my code I am trying to execute:

opr_operator_ods.Close;
opr_operator_ods.SetVariable('DATEFROM', opr_datefrom_dtp.Date);
opr_operator_ods.SetVariable('DATETO', opr_dateto_dtp.Date);
opr_operator_ods.SetVariable('TIMEFROM', opr_timefrom_dtp.Text);
opr_operator_ods.SetVariable('TIMETO', opr_timeto_dtp.Text);
opr_operator_ods.Open;

if opr_operator_ods.RecordCount > 0 then
begin
opr_operatorcount_ods.Close;
opr_operatorcount_ods.SetVariable('DATEFROM', opr_datefrom_dtp.Date);
opr_operatorcount_ods.SetVariable('DATETO', opr_dateto_dtp.Date);
opr_operatorcount_ods.SetVariable('TIMEFROM', opr_timefrom_dtp.Text);
opr_operatorcount_ods.SetVariable('TIMETO', opr_timeto_dtp.Text);
opr_operatorcount_ods.SetVariable('OPERATOR', opr_operator_ods.FieldByName('opr_code').AsString);
opr_operatorcount_ods.Open;

/* The old RaveReports code was here which would print each row and then move on to the next one and also progress the Master */

end
else
begin
MessageDlg('There is no data for this period to print.', mtInformation, [mbOK], 0);
end;

DecodeDate(opr_datefrom_dtp.Date, tyear, tmonth, tday);
StartDate := '''' + IntToStr(tday) + '/' + IntToStr(tmonth) + '/' + IntToStr(tyear) + '''';
DecodeDate(opr_dateto_dtp.Date, tyear, tmonth, tday);
EndDate := '''' + IntToStr(tday) + '/' + IntToStr(tmonth) + '/' + IntToStr(tyear) + '''';

frxReport1.Variables := StartDate;
frxReport1.Variables := EndDate;

frxReport1.PrepareReport(True);
frxReport1.ShowPreparedReport;

How do I get the report to loop through the detail and print each record for each master?

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.