Select between dates in query

UIK24

New Member
Joined
Apr 18, 2004
Messages
20
I am running a query form a form. I want to be able to display all records if no date is entered or the records between two dates if dates are entered.
In the criteria section of the query I have the code Like IIf(IsNull([forms]![leaveinfo]![text25]),"*",[Data]![Date of Absence] Between [Forms]![leaveinfo]![Text27] And [Forms]![leaveinfo]![Text25])
Text 25 is the start date and text27 is the end date.
If I run the query using just bewteen it works fine at retrieving the records between the two dates. If I use the IIf statement and leave the date field blank then all records are returned. If I use the IIf statement and enter dates no records are returned. Any Ideas?
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Are text25 and text27 formatted as dates?
That's the most common reason date stuff doesn't work. People don't realize it's formatted as text or something else...
 
Upvote 0
Yes. They are formatted as dates in the table and on the input form. I have also checked they are the same format!
 
Upvote 0

Forum statistics

Threads
1,221,687
Messages
6,161,287
Members
451,695
Latest member
Doug Mize 1024

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top