Show all records if parameter on form is empty

Equine Investor

Board Regular
Joined
Nov 20, 2002
Messages
103
Hi guys,

I've searched everywhere for this one, so any help appreciated.

I have a form with minimum and maximum parameters for a query and if EITHER of the minimum or maximum fields or both of them are left blank, then it should return all records.

Here is my criteria:

Between [Forms]![SEARCH]![TABMin] And [Forms]![SEARCH]![TABMax]

Now what I need is if either TABMin or TABMax or both are left blank that the query returns all records!

I've found some solutions, but not incorporating the two parameters - only one.

Any gurus help please?
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Can you program it so:

If [Forms]![SEARCH]![TABMin] is blank, set it equal to #01/01/1900#
If [Forms]![SEARCH]![TABMax] is blank set it equal to #12/31/2099#

or something of the sort?

If you haven't already done it, it will probably require VBA instead of just trying to do a parameter query.
 
Upvote 0
Thanks for the reply jmiskey.

No, it would not achieve the objective.

I see what your solution is trying to do, but I need to incorporate all of it into the BETWEEN and AND statements.

"Between [Forms]![SEARCH]![TABMin] And [Forms]![SEARCH]![TABMax]"

I'm sure it can be expressed, but need some help in building the statement.

Here is my literal statement without the code that I need:

If [Forms]![SEARCH]![TABMin]="" and/or [Forms]![SEARCH]![TABMax]="" then show all records, otherwise show Between [Forms]![SEARCH]![TABMin] And [Forms]![SEARCH]![TABMax]

I just can't get the expression right???
 
Upvote 0
SOLUTION FOR ANYONE SEARCHING LATER....

between Nz([Forms]![SEARCH]![TABMin],0)
and Nz([Forms]![SEARCH]![TABMax],999999)

BUT - my problem was that not all records were populated by a TAB value, therefore it only showed those records where a value lay rather than all records.

The solution was to populate the field TAB with 0 values where the value was empty.
 
Upvote 0

Forum statistics

Threads
1,214,838
Messages
6,121,885
Members
449,057
Latest member
Moo4247

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