iif & like

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to create a criteria that references a form and shows multiple
names. For instance:
IIf([Forms]![frmDateMenu5]![Check104]=1,Like "lewis",Null)

In this case the [Check104] =1 and the output should be:
Lewis4
Lewis8
Lewis30

However, my code is showing a null value. What am I doing wrong?
 
thanks for the reply. I am still having problems getting this combination of
iif and like to work properly. When I try hardcoded terms like "lewis4",
"lewis8", "lewis30" on three seperate attempts my query works great.
However, the suggested wildcard doesn't seem to be doing the trick. Any
other thoughts?

Klatuu said:
IIf([Forms]![frmDateMenu5]![Check104]=1,Like "lewis*",Null)


briank said:
I am trying to create a criteria that references a form and shows multiple
names. For instance:
IIf([Forms]![frmDateMenu5]![Check104]=1,Like "lewis",Null)

In this case the [Check104] =1 and the output should be:
Lewis4
Lewis8
Lewis30

However, my code is showing a null value. What am I doing wrong?
 
I think I see the problem after rereading your code. if Chk104 is a check
box, it will never be = 1. Check boxes only return True or False. True is
-1 and False is 0.
Try this:

IIf([Forms]![frmDateMenu5]![Check104],Like "lewis*",Null)

You could say

IIf([Forms]![frmDateMenu5]![Check104] = True,Like "lewis*",Null)

But the = True is not necessary

briank said:
thanks for the reply. I am still having problems getting this combination of
iif and like to work properly. When I try hardcoded terms like "lewis4",
"lewis8", "lewis30" on three seperate attempts my query works great.
However, the suggested wildcard doesn't seem to be doing the trick. Any
other thoughts?

Klatuu said:
IIf([Forms]![frmDateMenu5]![Check104]=1,Like "lewis*",Null)


briank said:
I am trying to create a criteria that references a form and shows multiple
names. For instance:
IIf([Forms]![frmDateMenu5]![Check104]=1,Like "lewis",Null)

In this case the [Check104] =1 and the output should be:
Lewis4
Lewis8
Lewis30

However, my code is showing a null value. What am I doing wrong?
 
I have changed the sql as suggested but am still seeing null values with the
Like "Lewis*" verbage. Still scratching my head on this.

Klatuu said:
I think I see the problem after rereading your code. if Chk104 is a check
box, it will never be = 1. Check boxes only return True or False. True is
-1 and False is 0.
Try this:

IIf([Forms]![frmDateMenu5]![Check104],Like "lewis*",Null)

You could say

IIf([Forms]![frmDateMenu5]![Check104] = True,Like "lewis*",Null)

But the = True is not necessary

briank said:
thanks for the reply. I am still having problems getting this combination of
iif and like to work properly. When I try hardcoded terms like "lewis4",
"lewis8", "lewis30" on three seperate attempts my query works great.
However, the suggested wildcard doesn't seem to be doing the trick. Any
other thoughts?

Klatuu said:
IIf([Forms]![frmDateMenu5]![Check104]=1,Like "lewis*",Null)


:

I am trying to create a criteria that references a form and shows multiple
names. For instance:
IIf([Forms]![frmDateMenu5]![Check104]=1,Like "lewis",Null)

In this case the [Check104] =1 and the output should be:
Lewis4
Lewis8
Lewis30

However, my code is showing a null value. What am I doing wrong?
 
If the field is never null then you should be able to use

Like IIf([Forms]![frmDateMenu5]![Check104] = True,"lewis*","*")

If the field can be null then try

Like IIf([Forms]![frmDateMenu5]![Check104] = True,"lewis*","*") OR
[Forms]![frmDateMenu5]![Check104] = False



Klatuu said:
I think I see the problem after rereading your code. if Chk104 is a check
box, it will never be = 1. Check boxes only return True or False. True
is
-1 and False is 0.
Try this:

IIf([Forms]![frmDateMenu5]![Check104],Like "lewis*",Null)

You could say

IIf([Forms]![frmDateMenu5]![Check104] = True,Like "lewis*",Null)

But the = True is not necessary

briank said:
thanks for the reply. I am still having problems getting this
combination of
iif and like to work properly. When I try hardcoded terms like "lewis4",
"lewis8", "lewis30" on three seperate attempts my query works great.
However, the suggested wildcard doesn't seem to be doing the trick. Any
other thoughts?

Klatuu said:
IIf([Forms]![frmDateMenu5]![Check104]=1,Like "lewis*",Null)


:

I am trying to create a criteria that references a form and shows
multiple
names. For instance:
IIf([Forms]![frmDateMenu5]![Check104]=1,Like "lewis",Null)

In this case the [Check104] =1 and the output should be:
Lewis4
Lewis8
Lewis30

However, my code is showing a null value. What am I doing wrong?
 
Your object isn't real clear. What is clear is you can't place the "Like"
inside the IIf(). Try something like:

Like IIf([Forms]![frmDateMenu5]![Check104],"lewis*","zzz")
 
I would not have thought of putting the term "Like" in the front of the
command. Thanks to everyone for their help in getting this command to work
perfectly.

Duane Hookom said:
Your object isn't real clear. What is clear is you can't place the "Like"
inside the IIf(). Try something like:

Like IIf([Forms]![frmDateMenu5]![Check104],"lewis*","zzz")


--
Duane Hookom
MS Access MVP

briank said:
I am trying to create a criteria that references a form and shows multiple
names. For instance:
IIf([Forms]![frmDateMenu5]![Check104]=1,Like "lewis",Null)

In this case the [Check104] =1 and the output should be:
Lewis4
Lewis8
Lewis30

However, my code is showing a null value. What am I doing wrong?
 
Back
Top