ObiBenKenobi
New member
- Local time
- Today, 08:28
- Joined
- Jan 19, 2012
- Messages
- 8
Apologies if this is a duplicate thread.
I have a form where I would like users to filter a date range in a query.
Ideally, the users would be able to put a date in either, neither, or both of the designated text boxes to apply the proper date filter to the query.
I can reference form fields in my query easy enough, but my problem is that I don't know how to tell the query to show me everything if one or both of the text box fields are left blank. My problem is compounded because the query itself appropriately contains null values in the date column.
Here's what I want to say (and have tried countless times with nested IIfs, Betweens and a combination thereof):
(txtStartDate and txtEndDate are the text box fields on the form)
If txtStartDate and txtEndDate are null, don't apply any filter
If txtStartDate and txtEndDate are not null, filter between those two
If txtSartDate is null and txtEndDate is not null, filter from the beginning of time to txtEndDate, while showing no nulls
If txtStartDate is not null and txtEndDate is null, filter from txtStartDate to the end of time, while showing no nulls
I don't know if I'm foolish for trying this in context of the query itself or if I should write some VBA to apply the filters.
Any help would be appriciated!
I have a form where I would like users to filter a date range in a query.
Ideally, the users would be able to put a date in either, neither, or both of the designated text boxes to apply the proper date filter to the query.
I can reference form fields in my query easy enough, but my problem is that I don't know how to tell the query to show me everything if one or both of the text box fields are left blank. My problem is compounded because the query itself appropriately contains null values in the date column.
Here's what I want to say (and have tried countless times with nested IIfs, Betweens and a combination thereof):
(txtStartDate and txtEndDate are the text box fields on the form)
If txtStartDate and txtEndDate are null, don't apply any filter
If txtStartDate and txtEndDate are not null, filter between those two
If txtSartDate is null and txtEndDate is not null, filter from the beginning of time to txtEndDate, while showing no nulls
If txtStartDate is not null and txtEndDate is null, filter from txtStartDate to the end of time, while showing no nulls
I don't know if I'm foolish for trying this in context of the query itself or if I should write some VBA to apply the filters.
Any help would be appriciated!