Query criteria - issues with IIF statement

btomjack

Board Regular
Joined
Sep 13, 2013
Messages
229
I have created a query that will pull data from a local table based on the values in a form control. Basically, the user enters the date they want to search in the text box, and the query only pulls data that has that date. The criteria ends up looking something like this:


IIF(ISNULL(textbox.value),>#1/1/1901#,textbox.value)


The problem arises when the text box is blank. I want to set up a criteria like > #1/1/1901# or "Is Not Null" so that it will pull all data. If I put any of these criteria in by themselves (without the IIF statement), they work perfectly. It even works when I put in a single value (i.e. #12/4/2013# pulls only the data from December 4, 2013; note that there is no ">" in that statement).


Basically, the IIF statement works, and both the "true" and "false" statements operate correctly. The problem is that Access is not correctly reading the ">" character if it is within an IIF statement.


Any help overcoming this issue will be greatly appreciated. Thanks in advance.
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
I figured it out. I created another query with the appropriate joins and used that queries' results as the true statement.
 
Upvote 0

Forum statistics

Threads
1,215,025
Messages
6,122,732
Members
449,093
Latest member
Mnur

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