Home End User
New Blog Posts: Merging Reports - Part 1 and Part 2

saving permanent dataview through code

edited January 2006 in End User
Hi,

I'm just trying to create a new dataview and populate it on behalf of
the user through code (so that the user can then modify it). However
when saving the template it gives me an access violation. If I comment
the data view creation out, it saves the template fine. Please help,
i've included my code below.

function TfrmCustomReport.GetDataView(const ADataModule: TdaDataModule;
const sViewName: string): TdaDataView;
var
i: Integer;
begin
Result := nil;
for i := 0 to ADataModule.DataViewCount - 1 do
if TdaDataView(ADataModule.DataViews[i]).Description = sViewName then
Result := TdaDataView(ADataModule.DataViews[i]);
if not Assigned(Result) then begin
Result := TdaDBISAMQueryDataView.Create(ADataModule);
Result.Name := sViewName;
Result.Parent := ADataModule;
TdaQueryDataView(Result).Init();
TdaQueryDataView(Result).Report.Template.Save();
end;
end;



Thanks in advance.

Comments

  • edited January 2006
    Jaweed Saleem wrote:

    I'm also using delphi 5 and reportbuilder 6.03 and DBISAM.
  • edited January 2006

    I think the problem is that you when you create the DataView you do not
    assign the Report property. Then you try to use the Dataview.Report property
    to save the report - which will be nil at that point. Try tracing the source
    code to see whether this is the case.

    A DataModule can have many DataViews - each dataview can be assigned to a
    different report/childreport. To associate the DataView with the main
    report, try

    myDataView.Report := myDataModule.Report;







    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited January 2006
    Nard Moseley (Digital Metaphors) wrote:

    That works like a charm. Thanks for your help
This discussion has been closed.