With a few minor tweaks I was able to get this to work for strings with either a singlequote, or doublequote present...the error trap also worked for when both type were present.
var
QuoteStr: char; //edit2: changed to char
UserLooksFor: string;
begin
UserLooksFor:=DBLookupcomboBox1.Text;
//quick and dirty:
if (pos('"',UserLooksFor)>0) and (pos('''',UserLooksFor)>0) then //edit2: fixed parens and quotes in second pos statement
begin
ShowMessage('cannot filter on both single and double quotes. sorry. please fix tdbf code.');
exit;
end
else if pos('''',UserLooksFor)>0 then {look for single quote} //edit2: fixed quotes
QuoteStr:='"' {double quote} //edit: argh, I had originally put in a single quote. sorry
else if pos('"',UserLooksFor)>0 then {look for double quote}
QuoteStr:='''' {single quote};
DBf1.Filter := 'LAST=' + AnsiQuotedStr(DBLookupcomboBox1.Text,QuoteStr);
DBF1.Filtered:= true;
The only problem is that it fails on values that don't have any quotes in them.
On a very simple level, this statement works for data where there is only a singlequote present:
Filter := FieldComboBox.Text + '=' + AnsiQuotedSTR(DBLookupcomboBox1.Text,'"')