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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADODB Recordset Filter problem

Status
Not open for further replies.

ultra2

Programmer
Jun 26, 2005
46
HU
dim rst as ADODB.Recordset
set rst = new ADODB.Recordset
rst.open select field1,field2 from table

rst.Filter = "(field1 = 100)" it works!
rst.Filter = "(field2 = 2 or field2 = 3)" it also works!

but it doesnt work:
rst.Filter = "(field1 = 100) and (field2 = 2 or field2 = 3)"
//Error: wrong type or conflict between parameters..

WHY?? plz help!!

 
thx,

you cannot group clauses joined by an OR and then join the group to another clause with an AND, like this:
(LastName = 'Smith' OR LastName = 'Jones') AND FirstName = 'John'
Instead, you would construct this filter as
(LastName = 'Smith' AND FirstName = 'John') OR (LastName = 'Jones' AND FirstName = 'John')

is there a function I can use to do this?
 
Keyboard?

You may also find that using a SQL WHERE statement will be better in many circumstances than pulling a whole tablesworth of data and then filtering it.

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top