Re: Filter error... but why?



ADO does not support filters in form A AND (B OR C). Instead you should
write (A AND B) OR (A AND C). This is from MSDN:

There is no precedence between AND and OR. Clauses can be grouped within
parentheses. However, 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')

//------------------------------------------
Regards,
Vassiliev V. V.
http://www.managed-vcl.com - using .Net objects in Delphi for Win32 +
ADO.Net
http://www.oledbdirect.com - The fastest way to access MS SQL Server,
MS Jet (Access) and Interbase (through OLEDB)


"Mike Niemann" <mniemann@xxxxxxxxxxxxx> ÓÏÏÂÝÉÌ/ÓÏÏÂÝÉÌÁ × ÎÏ×ÏÓÔÑÈ
ÓÌÅÄÕÀÝÅÅ: news:430b447c@xxxxxxxxxxxxxxxxxxxxxxxxx
> TDataset filtering... filter looks good, why the exception?
>
> Filter - ( ([LastName] like 'm%')) AND (IdNumber = '333-33-1111' or
> IdNumber
> = '333-33-1112' or IdNumber = '333-33-1113' or IdNumber = '333-33-1114' or
> IdNumber = '333-33-1115')
>
> Exception - Arguments are of the wrong type, are out os acceptable range,
> or
> are in conflict with one another.
>
> Regards, Mike Niemann
>
>


.



Relevant Pages

  • Re: ADODB & Recordset.Filter -> Problem mit Verkettung
    ... angeschaut und da steht: ... This error can occur if the filter syntax is incorrect. ... and grouping clauses with parentheses. ...
    (microsoft.public.de.vb.datenbank)
  • Re: Filter Recordset
    ... Julio wrote: ... you cannot group clauses joined by an OR and then join ... you would construct this filter as ... You will get a quicker response by posting to the newsgroup. ...
    (microsoft.public.scripting.vbscript)
  • RE: Use Filter To Print This Record Only
    ... The quotes in Where clauses always mess me up, ... "Bonnie" wrote: ... >> Filter Property. ...
    (microsoft.public.access.formscoding)
  • Re: Write to and store data in a listbox
    ... clause into a string and apply it to the form's filter. ... most-used WHERE clauses. ... Build a table with 3 or more columns: UserID, Description, ... Populate the listbox from the table. ...
    (comp.databases.ms-access)
  • Re: Structured Exception Handling (was: Try Finally...)
    ... >> exception handlers and termination handlers. ... >> exception filtering, except clauses, and finally clauses, is up to ... > exception handler related to the stopping exception filter. ...
    (comp.lang.pascal.delphi.misc)