What is the best way to create an OPTIONAL date filter on a form?
I'm completely stumped.
I have a query/form combination in which i would like the user to be able to select a date range only if they want to. So my form has a textbox named FromDate and another textbox named ToDate. These values will be used in the criteria line in the query that feeds the form. The field that I want to filter on in the query is ActivityDate.
Here's where everything starts breaking down. I can use a Between statement using those textbox values and it works fine.
The query works fine with this statement in the criteria line.
Between [Fromdate] And [Todate]
However, when I try to add an iif statement into the criteria to make the criteria optional, I get no results.
This is what my latest attempt looks like...
IIf([FromDate] Is Not Null And [ToDate] Is Not Null,Between [Fromdate] And [Todate],[Activitydate])
now i've tried several combinations of nulls and " " and whatever else i can think of and nothing works but I am willing to try any suggestions anybody has.
Are the textboxes even the right way to go for something like this? I don't want to paint myself into a corner by thinking I NEED to use textboxes. Any help would be greatly appreciated...
I'm completely stumped.
I have a query/form combination in which i would like the user to be able to select a date range only if they want to. So my form has a textbox named FromDate and another textbox named ToDate. These values will be used in the criteria line in the query that feeds the form. The field that I want to filter on in the query is ActivityDate.
Here's where everything starts breaking down. I can use a Between statement using those textbox values and it works fine.
The query works fine with this statement in the criteria line.
Between [Fromdate] And [Todate]
However, when I try to add an iif statement into the criteria to make the criteria optional, I get no results.
This is what my latest attempt looks like...
IIf([FromDate] Is Not Null And [ToDate] Is Not Null,Between [Fromdate] And [Todate],[Activitydate])
now i've tried several combinations of nulls and " " and whatever else i can think of and nothing works but I am willing to try any suggestions anybody has.
Are the textboxes even the right way to go for something like this? I don't want to paint myself into a corner by thinking I NEED to use textboxes. Any help would be greatly appreciated...