Can't filter a report
Hi,
I am trying to print a very simple report for a sales receipt, with the
customer's details on the top and their purchases one to a line below. The
trouble is, it prints the first customer's details and then all the
purchases for everybody! The code to open the report is:
procedure TPosForm.BitBtnReceiptClick(Sender: TObject);
var test: TppAutoSearchField;
begin
try
with MainDataModule.ppReport1 do
begin
MainDataModule.AdvantageReport.IsConnected := FALSE;
MainDataModule.AdvantageReport.ConnectPath :=
MainDataModule.MainAdsConnection.ConnectPath;
MainDataModule.AdvantageReport.IsConnected := TRUE;
Template.FileName := 'c:\possys 300\reports\receipt.rtm';
Template.LoadFromFile;
ShowAutoSearchDialog := FALSE;
CreateAutoSearchField('SALES', 'SERIALNO', '', dtstring, soEqual, '',
FALSE);
AutoSearchFields[0].SearchExpression := ''''+DBSerialNo.Text+'''';
PrinterSetUp.DocumentName := 'Receipt';
DeviceType := dtScreen;
Print;
end;
finally
MainDataModule.AdvantageReport.IsConnected := FALSE;
end;
end;
I have tried to use AutoSearchFields at lines 13 and 14 to filter the
records, but the system just ignores this. I read in the help that you need
to make an OnGetAutoSearchValues event in the report object to put the
search conditions into the data access objects, but what data access
objects? We just have a data dictionary in Report Builder and select tables
from it in the RB Query Designer.
I am using Delphi Enterprise Version 6.0 (build 6.240) and Report Builder
Enterprise Edition Version 6.03. I have attached the report file.
Any help would be much appreciated.
Regards
Martin Houlton
P. C. Data
I am trying to print a very simple report for a sales receipt, with the
customer's details on the top and their purchases one to a line below. The
trouble is, it prints the first customer's details and then all the
purchases for everybody! The code to open the report is:
procedure TPosForm.BitBtnReceiptClick(Sender: TObject);
var test: TppAutoSearchField;
begin
try
with MainDataModule.ppReport1 do
begin
MainDataModule.AdvantageReport.IsConnected := FALSE;
MainDataModule.AdvantageReport.ConnectPath :=
MainDataModule.MainAdsConnection.ConnectPath;
MainDataModule.AdvantageReport.IsConnected := TRUE;
Template.FileName := 'c:\possys 300\reports\receipt.rtm';
Template.LoadFromFile;
ShowAutoSearchDialog := FALSE;
CreateAutoSearchField('SALES', 'SERIALNO', '', dtstring, soEqual, '',
FALSE);
AutoSearchFields[0].SearchExpression := ''''+DBSerialNo.Text+'''';
PrinterSetUp.DocumentName := 'Receipt';
DeviceType := dtScreen;
Print;
end;
finally
MainDataModule.AdvantageReport.IsConnected := FALSE;
end;
end;
I have tried to use AutoSearchFields at lines 13 and 14 to filter the
records, but the system just ignores this. I read in the help that you need
to make an OnGetAutoSearchValues event in the report object to put the
search conditions into the data access objects, but what data access
objects? We just have a data dictionary in Report Builder and select tables
from it in the RB Query Designer.
I am using Delphi Enterprise Version 6.0 (build 6.240) and Report Builder
Enterprise Edition Version 6.03. I have attached the report file.
Any help would be much appreciated.
Regards
Martin Houlton
P. C. Data
This discussion has been closed.
Comments
Since you are using DADE, there is no need to create the AutoSearch fields
in code. You can create them on the fly inside the Query Designer.
Inside the Query Designer, click the "Search" tab and double click the field
you would like to search on. From there you can set the search expression
and search operator. Then be sure to click the check mark to enable
AutoSearch and make it mandatory if you need.
Of course if you do not want to use the autosearch dialogs, there is no need
to even click this option.
--
Thanks for supporting ReportBuilder! Please vote for ReportBuilder in the
Delphi Informant Readers Choice awards!
http://www.delphizine.com/ballot2004/
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com