L
Lori
Okay. I'm still having problems with a query by form.
I am querying a field (DateComp – type Date) in a table (t_Requests).
On form (1_Main) there's an option group (Status_Grp): Closed (value
1/Default), Open (value 2), All (value 3).
If they select Closed I want all DateComp records with values, ie "*"
If they select Open I want all DateComp records that are null, ie "Is Null"
If they select All I want all DateComp records.
For ease of testing I'm using I'm just seeing if I can't it to work using
option value 1 and simply changing the true statement.
Like IIf([Forms]![1_Main]![Status_Grp]=1,"*") This works great, I get 3
expected records.
My problem is when I try to find either only Null or All records.
Like "*" Or Is Null - Gives me all 15 records.
Is Null – Gives me 12 records
When I embed I get no records:
Like IIf([Forms]![1_Main]![Status_Grp]=1,Is Null)
the SQL is: Like IIf([Forms]![1_Main]![Status_Grp]=1,(t_Requests.DateComp)
Like "*" Or (t_Requests.DateComp) Is Null))
Access then converts the query criteria to: Like
IIf([Forms]![1_Main]![Status_Grp]=1,([t_Requests].[DateComp]) Like "*" Or
([t_Requests].[DateComp]) Is Null)
I found MSKB #209261 Showing All Records (Including Null) in a Parameter
Query and created a text control for the DateComp field setting its
visibility to No.
Like IIf([Forms]![1_Main]![Status_Grp]=1,(Like [Forms]![1_Main]![DateComp] &
"*" Or [Forms]![1_Main]![DateComp] Is Null))
The SQL ends up w/this:
(t_Requests.DateComp) Like
IIf([Forms]![1_Main]![Status_Grp]=1,((t_Requests.DateComp) Like
[Forms]![1_Main]![DateComp] & "*" Or [Forms]![1_Main]![DateComp] Is Null)))
and no results.
But if I the IIF portion of the criteria and just leave it:
(Like [Forms]![1_Main]![DateComp] & "*" Or [Forms]![1_Main]![DateComp] Is
Null)
I get all 15 records.
I am querying a field (DateComp – type Date) in a table (t_Requests).
On form (1_Main) there's an option group (Status_Grp): Closed (value
1/Default), Open (value 2), All (value 3).
If they select Closed I want all DateComp records with values, ie "*"
If they select Open I want all DateComp records that are null, ie "Is Null"
If they select All I want all DateComp records.
For ease of testing I'm using I'm just seeing if I can't it to work using
option value 1 and simply changing the true statement.
Like IIf([Forms]![1_Main]![Status_Grp]=1,"*") This works great, I get 3
expected records.
My problem is when I try to find either only Null or All records.
Like "*" Or Is Null - Gives me all 15 records.
Is Null – Gives me 12 records
When I embed I get no records:
Like IIf([Forms]![1_Main]![Status_Grp]=1,Is Null)
the SQL is: Like IIf([Forms]![1_Main]![Status_Grp]=1,(t_Requests.DateComp)
Like "*" Or (t_Requests.DateComp) Is Null))
Access then converts the query criteria to: Like
IIf([Forms]![1_Main]![Status_Grp]=1,([t_Requests].[DateComp]) Like "*" Or
([t_Requests].[DateComp]) Is Null)
I found MSKB #209261 Showing All Records (Including Null) in a Parameter
Query and created a text control for the DateComp field setting its
visibility to No.
Like IIf([Forms]![1_Main]![Status_Grp]=1,(Like [Forms]![1_Main]![DateComp] &
"*" Or [Forms]![1_Main]![DateComp] Is Null))
The SQL ends up w/this:
(t_Requests.DateComp) Like
IIf([Forms]![1_Main]![Status_Grp]=1,((t_Requests.DateComp) Like
[Forms]![1_Main]![DateComp] & "*" Or [Forms]![1_Main]![DateComp] Is Null)))
and no results.
But if I the IIF portion of the criteria and just leave it:
(Like [Forms]![1_Main]![DateComp] & "*" Or [Forms]![1_Main]![DateComp] Is
Null)
I get all 15 records.