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

autosearchfields

edited April 2007 in General
I wish to fill a autosearch field when it is present and then not show it in
the autosearchdialog,
I tried to disable the field when it is present and then add it again, that
succeeds but the report does not consider the criterium added.
so it does print all the reports even if the BE_ID is nto equal.


Underneith the code I use.

procedure TfrmMain.LoadReport(AReportItem: TReportItem);
var
ReportCanStart: Boolean;
i: Integer;
J: Integer;
Tabel: string;
Veld : string;
SearchFieldNr : integer;

begin
ppViewer1.Color := $00FAE3D3;
ppViewer1.Report := dmReport.ppReport;
Tabel := '';
Veld := '';
//Default zijn alle rapporten op te slaan


ReportCanStart := True;
ppViewer1.Reset;


// pnlReportViewer.Visible := True;
// bdcRapporten.Visible := True;
// pnlBeoordelingMappen.Visible := False;
dmReport.ppReport.ShowAutoSearchDialog := True;

dmReport.SelectReport(AReportItem.Id, AReportItem.ParentFolderId);

dmReport.ppReport.Template.DatabaseSettings.Name := AReportItem.Name;

dmReport.ppReport.Template.LoadFromDatabase;
//dmReport.ppReport.AutoSearchFields[0].SearchExpression :=
IntToStr(ActiveAdministratie.BedrijfsId);
if dmReport.ppReport.AutoSearchFieldCount > 0 then
begin
//ShowMessage(dmReport.ppReport.AutoSearchFields[0].FilterString);
for i := 0 to dmReport.ppReport.AutoSearchFieldCount - 1 do
begin
for J := 0 to
Length(dmReport.ppReport.AutoSearchFields[i].FilterString)-4 do
begin
if
Copy(dmReport.ppReport.AutoSearchFields[i].FilterString,J,5)='BE_ID' then
begin
Tabel:= dmReport.ppReport.AutoSearchFields[i].TableName;
Veld := dmReport.ppReport.AutoSearchFields[i].FieldName;
SearchFieldNr := i;
end;
end;
end;
if veld <>'' then
begin
dmReport.ppReport.AutoSearchFields[SearchFieldNr].DisableCriteria;
end;
ReportCanStart := dmReport.ppReport.DisplayAutoSearchDialog;
end;
if dmReport.ppReport.AutoSearchFieldCount > 0 then
begin
if Veld<>'' then
begin
SearchFieldNr := dmReport.ppReport.AutoSearchFieldCount;
dmReport.ppReport.CreateAutoSearchField(Tabel,Veld,'Bedrijfs
ID',dtInteger,soEqual,IntToStr(ActiveAdministratie.BedrijfsId),False) ;
// dmReport.ppReport.AutoSearchFields[SearchFieldNr].SearchExpression
:= IntToStr(ActiveAdministratie.BedrijfsId);
end;
end;
if ReportCanStart then
begin
dmReport.ppReport.PrintToDevices;
dmReport.AllowSaveAll;
dpnlAfdrukken.Caption := 'Afdrukken - ' + AReportItem.Name;
end
else
begin
// MessageDlg('Rapport geannuleerd', mtConfirmation, [mbOK], 0);
end;

regards,
Rob Nowee

Comments

  • edited April 2007
    Hi Rob,

    Where is your data defined? If you are using DADE, I would strongly
    recommend creating and altering your search criteria using the SQLBuilder
    object. This makes the process of creating and deleting criteria very
    simple so there would be no need to disable the search criteria, you could
    simple create and remove it as you need. Take a look at the TdaSQLBuilder
    topic in the RBuilder help for more information and code examples.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.