Return value and null from query

bschulze

Active Member
Joined
Jun 2, 2005
Messages
289
I have a query that is evaluating criteria and returning values. The evaluation is working properly but I'm having a hard time getting the results I desire. The field in the query is a Text field. I usually get an complication error unless I use the Like clause. The list of criteria I've tried never returns the null values, only the items that contain data if at all. When I drop the is null from the true statement and put it on a separate line it works, problem is as expected in that case, it picks up nulls for both the true and false conditions.

Query Criteria:
IIF(DMax("P","tblP")=[Forms]![frm1].[cbo1],DMax("P","tblP") or is null,[Forms]![frm1].[cbo1])

Simplified:
IIF(a=b,a or is null,b)


What I've tried so far:
IIF(a=b,a or is null,b)
IIF(a=b,a and is null,b)
Like IIF(a=b,a or is null,b)
Like IIF(a=b,a and is null,b)
IIF(a=b,Like a or is null,b)
IIF(a=b,Like a and is null,b)



Any thoughts would be greatly appreciated, I think I'm just overlooking something easy.
 
Your first suggestion will work perfect for me, very creative with the NZ(). Since I'm loading a subform with this query I want to stay away from UNIONS if possible, but can see that would also fit the bill. Thanks again.
 
Upvote 0

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
NP. Confused me at first but glad we sorted it out.
 
Upvote 0

Forum statistics

Threads
1,221,816
Messages
6,162,149
Members
451,746
Latest member
samwalrus

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