I have designed quite a few reports for my clients via the EU reporting I setup in the application. Everything is fine there but how do I open those reports dynamically from the application? How would I set the autosearch criteria when doing this?
You can load them by calling Report.Template.LoadFromDatabase. Be sure to configure the Report.Template.Datasettings property first so that it can find the database table.
We this code for printing forms in our applications-
procedure PrintForm(FormName:string;IDvalue:integer); begin frmforms := Tfrmforms.create(application); with frmForms do begin SearchCriteria := inttostr(idvalue); ppreport.template.DatabaseSettings.Name := Formname; ppreport.template.LoadFromDatabase; ppreport.OnPreviewFormCreate := FrmFORMS.CreatePreview; try ppreport.Print; Except // wrap up ShowMessage('Form Not Found'); end; end; // with frmforms.Free; frmforms := nil; end;
That procedure allows us to call the printform() from anywhere in our app and we just tell it what form we want to print and what value we want to set (in our case it's always an ID number for a sales order, Bill of Material, etc).
Then we set the value in the BeforeAutoSearchDialog (as shown below). lastly, we tell it to NOT show the autosearch dialog.
procedure TFrmFORMS.ppReportBeforeAutoSearchDialogCreate( Sender: TObject); begin ppReport.AutoSearchFields[0].SearchExpression := SearchCriteria; if not istesting then ppreport.showAutoSearchDialog := False; end;
Comments
configure the Report.Template.Datasettings property first so that it can
find the database table.
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
How would I set the autosearch values dynamically and prevent the
autosearch dialog from appearing?
We this code for printing forms in our applications-
procedure PrintForm(FormName:string;IDvalue:integer);
begin
frmforms := Tfrmforms.create(application);
with frmForms do
begin
SearchCriteria := inttostr(idvalue);
ppreport.template.DatabaseSettings.Name := Formname;
ppreport.template.LoadFromDatabase;
ppreport.OnPreviewFormCreate := FrmFORMS.CreatePreview;
try
ppreport.Print;
Except // wrap up
ShowMessage('Form Not Found');
end;
end; // with
frmforms.Free;
frmforms := nil;
end;
That procedure allows us to call the printform() from anywhere in our
app and we just tell it what form we want to print and what value we
want to set (in our case it's always an ID number for a sales order,
Bill of Material, etc).
Then we set the value in the BeforeAutoSearchDialog (as shown below).
lastly, we tell it to NOT show the autosearch dialog.
procedure TFrmFORMS.ppReportBeforeAutoSearchDialogCreate(
Sender: TObject);
begin
ppReport.AutoSearchFields[0].SearchExpression := SearchCriteria;
if not istesting then
ppreport.showAutoSearchDialog := False;
end;
Hope that helps.
Chris
Thank You