Re: Recordset Filter property and NULL

From: Mark J. McGinty (mmcginty_at_spamfromyou.com)
Date: 02/23/05


Date: Wed, 23 Feb 2005 01:54:47 -0800


"shadow123" <shadow123@discussions.microsoft.com> wrote in message
news:B30783AB-0F55-44F0-AEDA-5A70D9A08119@microsoft.com...
> From what I read about ADO's Recordset's filter property the Value of the
> Filter criteria can not be NULL. Is there any way at all I could use the
> filter to screen for NULL and non-NULL values or am I pretty much doomed
> to
> modifying the WHERE clause.
>
> Something I would like to do but can't. Any ideas are welcome
> recordset.Filter = "FIELD1 IS NULL";
>
> Thank you so much.

What I've ended up doing to fill the same need is something of a kludge, but
it does work. I derive an additional field, passing the field that could be
null to COALESCE(), to provide a sort-of pseudo-null that can be tested
using recordset.Filter, e.g.,

SELECT *, COALESCE([field_could_be_null], '{{is_null}}') As test_for_null
FROM MyTable

Then I can filter using "test_for_null = '{{is_null}}'"

Note that my example is written for SQL Server, but most if not all db
engines support a comparable construct.

Good Luck,
Mark



Relevant Pages

  • Filter Criteria - Excel 2007
    ... I'm trying to show the filter criteria when printing. ... I can manually select all three values from the auto filter list. ... can someone offer some VBA code to show more than 2 criteria? ...
    (microsoft.public.excel.misc)
  • Re: Do..Loop
    ... Are you asking for multiple filter criteria and/or filter fields? ... In any event both can be set by passing values to the autofilter method. ... Sub ReadDatal ... But the code only solve the one filter criteria. ...
    (microsoft.public.excel.programming)
  • Re: setting up UserForm for filter criteria
    ... One filter criteria is a list of one or more of three items. ... be in the UserForm? ... Can I hide the UserForm to display these other boxes ... One filter criteria is a list of one or more of three items. ...
    (microsoft.public.excel.programming)
  • Re: Removing Filter Criteria from the Forms Filter Property
    ... Hallie, does it matter if the Filter property is kept? ... setting FilterOn to False is all I ... that at least the filter criteria would be removed when the form was ...
    (microsoft.public.access.formscoding)
  • blank form when filter applied
    ... I have a form with employee details like name, age, ID, and ... The user then presses a button to set the filter. ... When there are no records that meet the filter criteria, ... I would like it to happen that when the user presses the ...
    (microsoft.public.access.formscoding)