form filtering

D

Damon Heron

I have the following code in an option group:

Private Sub optFilters_AfterUpdate()
If optFilters = 2 Then
Me.Filter = "forms!frmOrders!txtCompletedDate= '""'"
Me.FilterOn = True
Else
Me.FilterOn = False
End If
End Sub

The problem is it only gives me a new form (blank record), ignoring the 9
orders that don't have a completeddate in them. Any ideas why? This is a
standard single form, tied to a table, and allows entry of new records....
 
M

Marshall Barton

Damon said:
I have the following code in an option group:

Private Sub optFilters_AfterUpdate()
If optFilters = 2 Then
Me.Filter = "forms!frmOrders!txtCompletedDate= '""'"
Me.FilterOn = True
Else
Me.FilterOn = False
End If
End Sub

The problem is it only gives me a new form (blank record), ignoring the 9
orders that don't have a completeddate in them. Any ideas why? This is a
standard single form, tied to a table, and allows entry of new records....


The filter needs to refer to a **field** in the form's
record source table/query, not a **control** on the form. I
can't tell from what you've posted, but maybe this is close:

Me.Filter = "CompleteDate = "" "

But if that really is a date type field, it will never
contain a zero length string. It would be Null if it has
not been assign a date value so the filter would be:

Me.Filter = "CompleteDate Is Null"
 
Top