Hello all!
I am trying to understand the programming behind an expression in access 2010.
I have 2 text boxes that are used as a start and end date (txtstartdate and txtenddate) on a FORM (form is testform).
Also on the form is a button that runs a query.
The query is designed and has a date column. In the criteria of the date column, I have the following code.
Between [Forms]![testform]![txtstartdate] And [Forms]![testform]![txtenddate]
Everything works perfectly and I am able to use my two text boxes with dates to limit what is returned from the query.
To add in extra flexibility, I would like the query to be able to handle a few other events.
Ideally, I would like to have it so that if nothing is entered in either text box, the query gives all entries without filtering at all.
If txtstartdate has a date, but txtenddate does not, I would like it to display all dates equal to or after txtstartdate.
Likewise, if txtstartdate is blank, but txtenddate has a date, I would like it to display all dates equal to or before txtenddate.
To accomplish this, I have tried to modify my existing expression, but I am not sure to how account for all situations, nor can I get it to work even slightly with the IIF.
This is what I am trying:
Like IIf([forms]![testform]![txtstartdate] is NULL and [forms]![testform]![txtenddate] is NULL,"*",Between [Forms]![testform]![txtstartdate] And [Forms]![testform]![txtenddate])
Any idea how I can make the expression do what I described above?
Thank you!