i'm trying to filter a table with 2 different filters, so that when a button is pressed the only records displayed are those with a certain Job_ID and those with the Type 'Private'. i have the following code:
if CBSearchType.Text = 'Private' then
begin
DBTravel.DataSource.DataSet.DisableControls;
DBTravel.DataSource.DataSet.Filtered := False;
DBTravel.DataSource.DataSet.Filter := ('Job_ID = '+edtAddJobID.Text) AND ('Type = '+QuotedStr('Private'));
DBTravel.DataSource.DataSet.Filtered := True;
DBTravel.DataSource.DataSet.First;
DBTravel.DataSource.DataSet.EnableControls;
end;
however when i try to compile the error message 'Operator not applicable to this operand type' is displayed, any suggestions? thanks
The filter property must be a string
DBTravel.DataSource.DataSet.Filter := Format('(Job_ID =%s) AND (Type=%s)',[edtAddJobID.Text,QuotedStr('Private')]);
DBTravel.DataSource.DataSet.Filter := Format('(Job_ID =%s) AND (Mode =%s)',[edtAddJobID.Text,QuotedStr(edtSearchMode.Text)]);
RRUZ 2012-04-04 20:12
I suppose that Filter
is a string. Hence, you have to give it a string.
'(Job_ID = ' + edtAddJobID.Text + ') AND (Type = ' + QuotedStr('Private') + ')';
(Job_ID = %d) AND ...
mjn 2012-04-04 18:31