I want to add a "Null" option to my combo boxes that I use to create and apply filters.
I have a form with many combo boxes which I use to filter a table within a form. I oncatenatethe combo box values together and then apply a filter. The combo boxes are populated by a query of the approporiate field in the table. This all works fine until I select the blank item which is a null then I receive the error "Action or Method requires at least one argument"
This is part of the code which builds my filter and it works but I am left with the error. I utilize the combo box (with filter in name) tag property to pass the name of the field I will be filtering. tag = [FieldToFilter] etc.
I tried this and it works for the null (no error) but leaves a combo box that doesn't really let the user know that a filter is being used as it is blank which is a bit confusing. When I added the code to change the combo box value with "Is Null" to tell the user it is being filtered then the filter crashes when the user picks another filter option (there are 10).
Is there as way to somehow concatenate "Null" on to my source query so the word "Null" shows in my combo box and still works in my filter? Somthing like an Excel filter
Thanks for any insight or pointers of where to look, I did a lot of searching but never found what I needed.
I have a form with many combo boxes which I use to filter a table within a form. I oncatenatethe combo box values together and then apply a filter. The combo boxes are populated by a query of the approporiate field in the table. This all works fine until I select the blank item which is a null then I receive the error "Action or Method requires at least one argument"
This is part of the code which builds my filter and it works but I am left with the error. I utilize the combo box (with filter in name) tag property to pass the name of the field I will be filtering. tag = [FieldToFilter] etc.
Code:
If Me![cboPlanOKDateFilter] <> "" Then
If sFilter = "" Then
sFilter = Me![cboPlanOKDateFilter].Tag & "= #" & Me![cboPlanOKDateFilter] & "#"
Else
sFilter = sFilter & " AND " & Me![cboPlanOKDateFilter].Tag & "= #" & Me![cboPlanOKDateFilter] & "#"
End If
Else
I tried this and it works for the null (no error) but leaves a combo box that doesn't really let the user know that a filter is being used as it is blank which is a bit confusing. When I added the code to change the combo box value with "Is Null" to tell the user it is being filtered then the filter crashes when the user picks another filter option (there are 10).
Code:
If IsNull(Me![cboPlanOKDateFilter]) Then
If sFilter = "" Then
sFilter = Me![cboPlanOKDateFilter].Tag & "= null"
Else
sFilter = sFilter & " AND " & Me![cboPlanOKDateFilter].Tag & "= null"
End If
Me![cboPlanOKDateFilter] = "Is Null"
End If
End If
Is there as way to somehow concatenate "Null" on to my source query so the word "Null" shows in my combo box and still works in my filter? Somthing like an Excel filter
Thanks for any insight or pointers of where to look, I did a lot of searching but never found what I needed.