TADOQuery Filter Errors

Hi all,

We have a SQL database that is being accessed over vpn from many offices.  In an effort to increase speed we are trying to use the filter property instead of rerunning the sql statement for various user actions.  With simple filters it seems to work fine, but eventually errors out with 'Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another'.  Is there any limit to parameters or any reason why this should be failing?  Here is an example of a filter I am using.  

((EcyToday = 1) AND ((Lookup_Name like '%dav%') OR (Acct#1 like '%dav%') OR (Acct#2 like '%dav%') OR (ARMAcct like '%dav%') OR (City like '%dav%') OR (State like '%dav%') OR (WorkPhone like '%dav%') OR (HomePhone like '%dav%') OR (CellPhone like '%dav%')))

If you run just the EcyToday = 1  OR you run just the second half, it works fine.  But it will not run with both sets of parameters.  

Any help is greatly appreciated!
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mike LittlewoodEngineerCommented:
I don't think you can do nested OR's like that with a separate AND on the outside using filtering.
Well from the short bit of testing I've done it doesnt seem to work.
Chipmunk77Author Commented:
Hmm..  you may be right..  I don't see anything in Delphi that says it shouldn't be allowed, but it sure doesn't like it.  
Any ideas on a workaround or a way to make it accept the changes?  I cannot go back to the server as this was the original setup (and still is when the user is not remote) and the time to push the volumes of data back for a search was too long.  
Chipmunk77Author Commented:
aha!  Found the answer on a translated site...
You cannot do ((A OR B)) AND (C)     but      you are allowed to do (A AND C) OR (A AND B)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mike LittlewoodEngineerCommented:
Yep thought I was right Chipmunk77 :o)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.