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

Filter for Null and Not null values?

Status
Not open for further replies.

ordendelfai

Technical User
Nov 8, 2002
187
US
I am trying to code a filter linked to 3 buttons that values are 1, 2 and 3 in an Option Group.

The filter criteria is if the user clicks button "1" in the option group, then the form will filter out any records that Do have a null value in a specific field.

If the user clicks button 2, then it filters out the records that Do Not have a null value.

Button 3 is show a show all button.

I have tried coding it several ways, my last attempt below. If you could tell me the proper way, would really appreciate it ;)>

~~~~~~~~~~Code~~~~~~~~~~~~~~`

Select Case optgrp_Coverage
Case Is = 1
Me.Filter = IsNotNull([txt_Volunteer])
Me.FilterOn = True
Case Is = 2
Me.Filter = IsNull([txt_Volunteer])
Me.FilterOn = True
End Select
 
Hi ordendelfai,

You could try:

Select Case optgrp_Coverage
Case 1
Me.Filter = Is NotNull([txt_Volunteer])
Me.FilterOn = True
Case 2
Me.Filter = IsNull([txt_Volunteer])
Me.FilterOn = True
Case else
DoCmd.ShowAllRecords
End Select

Bill
 
Billpower himself, awesome ;o)

So all I did was miss a space?....lol

I'll try it tomorrow at work and report back, thank you very much ;o)

~Orden
 
Ok, final version had to change to "Not IsNull", and also put " " after the Me.Filter.

Thanks for all your help ;)

Select Case optgrp_Coverage
'Filter out groups with no coverage
Case Is = 1
Me.Filter = "Not IsNull([Volunteer])"
Me.FilterOn = True
End If

'Filter out groups with Coverage
Case Is = 2
Me.Filter = "IsNull([Volunteer])"
Me.FilterOn = True
End If

'Show all Records
Case Is = 3
Me.Filter = ""
Me.FilterOn = True
End Select

~Orden
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top