Change Sort value at run time.
I am using RB7.04 with Delphi 7
Is there a way to change way that a report is sorted via Delphi code
I have two check boxes
if check Box1 is checked print report by last name;
if check box2 is checked print report by Customer Number
--
Thanks in advance and Have a great day!
Walt Kersten
Wkersten@wkersoft.com
Is there a way to change way that a report is sorted via Delphi code
I have two check boxes
if check Box1 is checked print report by last name;
if check box2 is checked print report by Customer Number
--
Thanks in advance and Have a great day!
Walt Kersten
Wkersten@wkersoft.com
This discussion has been closed.
Comments
DADE to access the data? If so, yes it is possible but it's been a long time
since I played with the data object.
Ed Dressel
Team DM
Ed is correct. Depending on how you are accessing your data, you will
either need to alter your query in Delphi or if you are using DADE, you can
access the SQL object and alter the SQL there. ReportBuilder 9 includes the
TdaSQLBuilder object which makes this task trivial.
The following article shows how to access the SQL object via code (if you
are using DADE).
-------------------------------------------------
Tech Tip: How to access the SQL object associated
with a Report created using DADE
-------------------------------------------------
TdaSQL is a class defined in daQClass.pas.
TdaSQL has a run-time interface for adding search Criteria,
etc. For an example see the EndUser\Custom DataViews example.
OR you can assign its SQLText property. Please note that
once you directly assign the SQLText property the Query tool
buttons such as Sort, Search can no longer be used.
uses
daDatMod;
function GetSQLObject(aReport: TppReport; var aSQL: TdaSQL): Boolean;
var
lDataModule: TdaDataModule;
lDataView: TdaDataView;
begin
aSQL := nil;
{get the datamodule}
lDataModule := daGetDataModule(aReport);
if (lDataModule <> nil) then
begin
lDataView := lDataModule.DataViews[0];
if (lDataView <> nil) and (lDataView is TdaQueryDataView) then
aSQL := TdaQueryDataView(lDataView).SQL;
end;
Result := (aSQL <> nil);
end;
--
Tech Support mailto:support@digital-metaphors.com
Digital Metaphors http://www.digital-metaphors.com
Once you've retrieved the SQL object, you can do something useful to it,
like adding criteria values:
procedure ppReport1BeforePrint(Sender: TObject);
var
lSQL: TdaSQL;
lFields: TStringList;
lCriteria: TdaCriteria;
liIndex: Integer;
begin
{get SQL object}
lSQL := GetSQLObject(ppReport1);
{if criteria have not been created, then add them}
if (lSQL.CriteriaCount = 0) then
begin
{get all available criteria fields}
lFields := TStringList.Create;
lSQL.AvailableCriteriaList(lFields);
{set string list entries to field names}
for liIndex := 0 to lFields.Count - 1 do
lFields[liIndex] := TdaField(lFields[liIndex]).FieldName;
{create order no criteria}
liIndex := lFields.IndexOf('OrderNo');
if (liIndex <> -1) then
begin
lCriteria := lSQL.SelectCriteria(liIndex);
lCriteria.Operator := dacoEqual;
end;
{create art code criteria}
liIndex := lFields.IndexOf('ArtCode');
if (liIndex <> -1) then
begin
lCriteria := lSQL.SelectCriteria(liIndex);
lCriteria.Operator := dacoEqual;
end;
{create begin/end date criteria}
liIndex := lFields.IndexOf('OrderDate');
if (liIndex <> -1) then
begin
lCriteria := lSQL.SelectCriteria(liIndex);
lCriteria.Operator := dacoBetween;
end;
lFields.Free;
end;
{set order no. search value}
lSQL.Criteria[0].Value := '1020';
{set art code search value}
lSQL.Criteria[1].Value := 'C';
{set begin/end date search value}
lSQL.Criteria[2].Value := '31/12/90,31/12/99';
end;
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com