Filter

  • Thread starter Thread starter Eric D.
  • Start date Start date
E

Eric D.

Hi,

I'm having a lot of trouble with the .Filter method. I'm
trying to have a clause that states; only show result that
have some field = to NULL.

I tried:
rstTemp.Filter = "someField IS NULL"
and
rstTemp.Filter = "ISNULL(someField)"
and
rstTemp.Filter = "someField = NULL"

Nothing works. Someone point me in the right direction.

TIA,
Eric
 
I'm having a lot of trouble with the .Filter method. I'm
trying to have a clause that states; only show result that
have some field = to NULL.

I tried:
rstTemp.Filter = "someField IS NULL"
and
rstTemp.Filter = "ISNULL(someField)"
and
rstTemp.Filter = "someField = NULL"

The .Filter method seems to need 2 recordsets to work
and would use the example you showed first i.e. "SomeField Is Null".

It's a bit confusing and it would probably easier just to create
the new filtered recordset from scratch!

Sub TestFilter()
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim rstTemp As DAO.Recordset

Set db = CurrentDb
'open a recordset
Set rst = db.OpenRecordset("Customer", dbOpenDynaset)
'add a filter
rst.Filter = "CustTelephone Is Null"
'base a new recordset on the old recordset filtered
Set rstTemp = rst.OpenRecordset

rst.MoveLast
rstTemp.MoveLast

Debug.Print "Original Records: " & rst.RecordCount _
& " Filtered Records: " & rstTemp.RecordCount

End Sub


Cheers,
Peter
 
Back
Top