Home How to run a Zeos filter code for multiple TZquery?
Reply: 1

How to run a Zeos filter code for multiple TZquery?

code8888
1#
code8888 Published in 2013-11-05 17:06:00Z

I used to use a single code for my filter queries, and tried it using multiple TZquery but it won't work. All the tables contain the client_id column, and I wanted for the code to search for the infos with the client id on the TEdit, it works for a single TZquery, but not for more than one. Thanks.

Here is the code I used:

zquery1.FilterOptions:=[foCaseInsensitive]; 
zquery1.Filtered := Length(Edit1.Text) > 0; 
if zquery1.Filtered then 
  zquery1.Filter := 'client_id like ' + 
       QuotedStr('' + Edit1.Text + '') // Zeos- Syntax 
else 
  zquery1.Filter := '';

zquery2.FilterOptions:=[foCaseInsensitive]; 
zquery2.Filtered := Length(Edit1.Text) > 0; 
if zquery2.Filtered then 
  zquery2.Filter := 'client_id like ' + QuotedStr('' + Edit1.Text + '') // Zeos- Syntax 
else 
  zquery2.Filter := '';

zquery3.FilterOptions:=[foCaseInsensitive]; 
zquery3.Filtered := Length(Edit1.Text) > 0; 
if zquery3.Filtered then 
  zquery3.Filter := 'client_id like ' + QuotedStr('' + Edit1.Text + '') // Zeos- Syntax 
else 
  zquery3.Filter := '';

zquery4.FilterOptions:=[foCaseInsensitive]; 
zquery4.Filtered := Length(Edit1.Text) > 0; 
if zquery4.Filtered then 
  zquery4.Filter := 'client_id like ' + QuotedStr('' + Edit1.Text + '') // Zeos- Syntax 
else 
  zquery4.Filter := '';
crefird
2#
crefird Reply to 2013-11-06 05:38:34Z

I only change a filter condition when filtered is false. So I would write your code as follows

zquery1.FilterOptions:=[foCaseInsensitive]; 
zquery1.Filtered := false;
if Length(Edit1.Text) > 0 then
begin
  zquery1.Filter := 'client_id like ' +  QuotedStr(trim(Edit1.Text)) ;
  zquery1.Filtered := true;
end;

zquery2.FilterOptions:=[foCaseInsensitive]; 
zquery2.Filtered := false;
if Length(Edit1.Text) > 0 then
begin
  zquery2.Filter := 'client_id like ' + QuotedStr('' + Edit1.Text + '') // Zeos- Syntax 
  zquery2.Filtered := true;
end;

zquery3.FilterOptions:=[foCaseInsensitive]; 
zquery3.Filtered := false;
if Length(Edit1.Text) > 0 then
begin
  zquery3.Filter := 'client_id like ' + QuotedStr('' + Edit1.Text + '') // Zeos- Syntax 
  zquery3.Filtered := true;
end;

zquery3.FilterOptions:=[foCaseInsensitive]; 
zquery3.Filtered := false;
if Length(Edit1.Text) > 0 then
begin
  zquery3.Filter := 'client_id like ' + QuotedStr('' + Edit1.Text + '') // Zeos- Syntax 
  zquery3.Filtered := true;
end;
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.434666 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO