Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Recordser.filter problem

Status
Not open for further replies.

griffitd

Programmer
Aug 20, 2002
189
GB
Hi

I'm applying a filter to a recordset (old from somebody else) using the rs.filter property

The columns all exists and this filter works:
rs.filter = "(Agent LIKE 'MIES%' OR [Air Agent] LIKE 'MIES%')"

This also works:
rs.filter = "(Agent LIKE 'MIES%' OR [Air Agent] LIKE 'MIES%') OR (Origin LIKE 'BangladhCR%')"

BUT this doesn't work:
rs.filter= "(Agent LIKE 'MIES%' OR [Air Agent] LIKE 'MIES%') AND (Origin LIKE 'BangladhCR%')"

Changing the OR to an AND generates the following error:
Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.

Thanks in advance.
 
It is a limitation of the Filter, I'm afraid. The MS documentation states:

MSDN said:
One restriction on these combinations is that OR clauses can only be used at the highest (major) level of the logical operation.

They even provide an example of an illegal criteria that pretty much matches yours. You'll just need to restructure the criteria slightly:

Code:
rs.filter= "(Agent LIKE 'MIES%' AND Origin LIKE 'BangladhCR%') OR ([Air Agent] LIKE 'MIES%' AND Origin LIKE 'BangladhCR%')"

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top