Paul Brooks
asked on
Populating data grid
Morning all
I need to populate a data grid using 2 criteria. The code i am trying is giving me a few problems as i am trying to set the SQL query for the first criteria and the filter for the second. The filter is working fine but i am having trouble with the SQL. There must be a more elegant way of doing this. My code so far is
procedure TFrmsalessearch.Button1Cli ck(Sender: TObject);
var
accno : string;
begin
Application.createform(Tfr mcontsearc h, frmcontsearch);
accno :=cmbsalesacc.text;
frmcontsearch.Sqlcontracts .Active:=f alse;
frmcontsearch.Sqlcontracts .SQL.Clear ;
frmcontsearch.Sqlcontracts .SQL.add(' select * from CONTRACT_INFO where CLIENT_CODE = '+cmbsalesacc.text);
frmcontsearch.Sqlcontracts .Active:=t rue;
frmcontsearch.SQLcontracts .Filter:=' CONTRACT_C OMPLETE=' + QuotedStr('N');
frmcontsearch.SQLcontracts .Filtered: =true;
Frmcontsearch.label1.Capti on := accno;
frmcontsearch.showmodal;
end;
Any ideas are most welcome
Best regards
I need to populate a data grid using 2 criteria. The code i am trying is giving me a few problems as i am trying to set the SQL query for the first criteria and the filter for the second. The filter is working fine but i am having trouble with the SQL. There must be a more elegant way of doing this. My code so far is
procedure TFrmsalessearch.Button1Cli
var
accno : string;
begin
Application.createform(Tfr
accno :=cmbsalesacc.text;
frmcontsearch.Sqlcontracts
frmcontsearch.Sqlcontracts
frmcontsearch.Sqlcontracts
frmcontsearch.Sqlcontracts
frmcontsearch.SQLcontracts
frmcontsearch.SQLcontracts
Frmcontsearch.label1.Capti
frmcontsearch.showmodal;
end;
Any ideas are most welcome
Best regards
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
'where CLIENT_CODE = '+cmbsalesacc.text
maybe the quotedstr is not needed (depends of the sql engine used):
frmcontsearch.Sqlcontracts
'where CLIENT_CODE = '+cmbsalesacc.text+
' and CONTRACT_COMPLETE=N');