iif function

J

JL

Where and how are you using them?
If you are using them in a form, IIF is like a function
that returns a value. Therefore, you have to assign them
to a variable or something similar.

For example,

Val1 = iif((([Text1]-11) >= [StartDate]) and (([Text1]-11)=
[Enddate])), [approved]+2, 0)

Another way to rewrite IIF is to use IF and ELSE.

For example,

if ([Text1]-11) >= [StartDate]) and _
([Text1]-11)=[Enddate]) then
Val1 = [approved]+2
else
Val1 = 0
end if

PS: There still might be problems if the [Text1] and
[StartDate] are different type.
 
L

lynda

Thanks!
I am using it in control source of a textBox in a
continuous form, I did put = before the iif since I want
it to return a value. The return value seems not it is
supposed to be, so I am trying to print it out from the
form event On Current. Even if I asign a value for example
integer Vall to the iff function, it complains "expected
end of statement ", it stops at "," , after the first iif
((([Text1]-11) >= [StartDate]) and (([Text1]-11)=
[Enddate])),
If I use Between, it complains it doesn't know Between.
Thanks!
Lynda
-----Original Message-----
Where and how are you using them?
If you are using them in a form, IIF is like a function
that returns a value. Therefore, you have to assign them
to a variable or something similar.

For example,

Val1 = iif((([Text1]-11) >= [StartDate]) and (([Text1]-11) =
[Enddate])), [approved]+2, 0)

Another way to rewrite IIF is to use IF and ELSE.

For example,

if ([Text1]-11) >= [StartDate]) and _
([Text1]-11)=[Enddate]) then
Val1 = [approved]+2
else
Val1 = 0
end if

PS: There still might be problems if the [Text1] and
[StartDate] are different type.
-----Original Message-----
I am trying to use iif function, but I don't know how to
get this work:
iif((([Text1]-11) >= [StartDate]) and (([Text1]-11)<=
[Enddate])), [approved]+2, 0)
or
iif((([Text1]-11) between [StartDate]) and [Enddate]),
[approved]+2, 0)
Anyway, if I cannot use iif, what other way I can use?
Thanks for your help!
Best Regards
Lynda
.
.
 
J

JL

Try this, I think you have one to many ")" in [Enddate].

iif((([Text1]-11) >= [StartDate]) and (([Text1]-11) >=
[Enddate]), [approved]+2, 0)

If the result is still not what you expected, then I have
to say the "Text1" and "StartDate" are different data
types.
Like "Text1" is Text Type and "StartDate" is Date Type.
Then you have to convert them to the same data type before
you do your comparision.

Hope this helps.
-----Original Message-----
Thanks!
I am using it in control source of a textBox in a
continuous form, I did put = before the iif since I want
it to return a value. The return value seems not it is
supposed to be, so I am trying to print it out from the
form event On Current. Even if I asign a value for example
integer Vall to the iff function, it complains "expected
end of statement ", it stops at "," , after the first iif
((([Text1]-11) >= [StartDate]) and (([Text1]-11)=
[Enddate])),
If I use Between, it complains it doesn't know Between.
Thanks!
Lynda
-----Original Message-----
Where and how are you using them?
If you are using them in a form, IIF is like a function
that returns a value. Therefore, you have to assign them
to a variable or something similar.

For example,

Val1 = iif((([Text1]-11) >= [StartDate]) and (([Text1]-
11)
=
[Enddate])), [approved]+2, 0)

Another way to rewrite IIF is to use IF and ELSE.

For example,

if ([Text1]-11) >= [StartDate]) and _
([Text1]-11)=[Enddate]) then
Val1 = [approved]+2
else
Val1 = 0
end if

PS: There still might be problems if the [Text1] and
[StartDate] are different type.
-----Original Message-----
I am trying to use iif function, but I don't know how to
get this work:
iif((([Text1]-11) >= [StartDate]) and (([Text1]-11)<=
[Enddate])), [approved]+2, 0)
or
iif((([Text1]-11) between [StartDate]) and [Enddate]),
[approved]+2, 0)
Anyway, if I cannot use iif, what other way I can use?
Thanks for your help!
Best Regards
Lynda
.
.
.
 
L

lynda

JL and Marsh,
Thanks! Sorry I messed up the datatype, {Text1] is not
date. That is the problem. Thanks alot!
Best regards
Lynda
-----Original Message-----
Try this, I think you have one to many ")" in [Enddate].

iif((([Text1]-11) >= [StartDate]) and (([Text1]-11) >=
[Enddate]), [approved]+2, 0)

If the result is still not what you expected, then I have
to say the "Text1" and "StartDate" are different data
types.
Like "Text1" is Text Type and "StartDate" is Date Type.
Then you have to convert them to the same data type before
you do your comparision.

Hope this helps.
-----Original Message-----
Thanks!
I am using it in control source of a textBox in a
continuous form, I did put = before the iif since I want
it to return a value. The return value seems not it is
supposed to be, so I am trying to print it out from the
form event On Current. Even if I asign a value for example
integer Vall to the iff function, it complains "expected
end of statement ", it stops at "," , after the first iif
((([Text1]-11) >= [StartDate]) and (([Text1]-11)=
[Enddate])),
If I use Between, it complains it doesn't know Between.
Thanks!
Lynda
-----Original Message-----
Where and how are you using them?
If you are using them in a form, IIF is like a function
that returns a value. Therefore, you have to assign them
to a variable or something similar.

For example,

Val1 = iif((([Text1]-11) >= [StartDate]) and (([Text1]-
11)
=
[Enddate])), [approved]+2, 0)

Another way to rewrite IIF is to use IF and ELSE.

For example,

if ([Text1]-11) >= [StartDate]) and _
([Text1]-11)=[Enddate]) then
Val1 = [approved]+2
else
Val1 = 0
end if

PS: There still might be problems if the [Text1] and
[StartDate] are different type.

-----Original Message-----
I am trying to use iif function, but I don't know how to
get this work:
iif((([Text1]-11) >= [StartDate]) and (([Text1]-11)<=
[Enddate])), [approved]+2, 0)
or
iif((([Text1]-11) between [StartDate]) and [Enddate]),
[approved]+2, 0)
Anyway, if I cannot use iif, what other way I can use?
Thanks for your help!
Best Regards
Lynda
.

.
.
.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top