By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,107 Members | 1,323 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,107 IT Pros & Developers. It's quick & easy.

IF in a query

P: n/a
I'm trying to put a function into a query. I want to check the
logical field "closed." If it's true, I want to return a text value
of "Closed". If false, I want to return a text value of "Not Yet."

Here's the value in the query:

Expr1: IF([closed],"Closed","Not Yet")

It accepts it without an error message, but when I try to display it I
get the error message "Undefined Function IF in expression." I've
tried using an equal sign in front of the if, but the program strips
it as soon as you leave the cell. I've tried it with "closed"
unbracketed, with the database name included, with closed=0, and none
of them work.

What do I need to do to make this work?

Dave Hitt
----
Why smoking bans kill businesses
http://www.davehitt.com/april03/homebody.html
Nov 12 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
"Dave Hitt" <Bo****************@nycap.rr.com> wrote in message
news:md********************************@4ax.com...
I'm trying to put a function into a query. I want to check the
logical field "closed." If it's true, I want to return a text value
of "Closed". If false, I want to return a text value of "Not Yet."

Here's the value in the query:

Expr1: IF([closed],"Closed","Not Yet")

It accepts it without an error message, but when I try to display it I
get the error message "Undefined Function IF in expression." I've
tried using an equal sign in front of the if, but the program strips
it as soon as you leave the cell. I've tried it with "closed"
unbracketed, with the database name included, with closed=0, and none
of them work.

What do I need to do to make this work?


The function your looking for is called Immediate-If and is written as...
IIf(Test,ReturnIfTrue, ReturnIfFalse)

So in your case...
Expr1: IIf([closed],"Closed","Not Yet")

--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com
Nov 12 '05 #2

P: n/a
Expr1: IIF([closed],"Closed","Not Yet")

You nearly had it. <g>

P
"Dave Hitt" <Bo****************@nycap.rr.com> wrote in message
news:md********************************@4ax.com...
I'm trying to put a function into a query. I want to check the
logical field "closed." If it's true, I want to return a text value
of "Closed". If false, I want to return a text value of "Not Yet."

Here's the value in the query:

Expr1: IF([closed],"Closed","Not Yet")

It accepts it without an error message, but when I try to display it I
get the error message "Undefined Function IF in expression." I've
tried using an equal sign in front of the if, but the program strips
it as soon as you leave the cell. I've tried it with "closed"
unbracketed, with the database name included, with closed=0, and none
of them work.

What do I need to do to make this work?

Dave Hitt
----
Why smoking bans kill businesses
http://www.davehitt.com/april03/homebody.html

Nov 12 '05 #3

P: n/a
Dave,
There is a simpler way than trying to do this in the query.
(You've already been told about using IIf instead of If.)

Is the query going to be used as a report record source?
If so, and the field [Closed] is a Check box field, just let the query
show the actual check value of -1 or 0.

In the report, simply add the check box field to the report.
Set it's Format property to:
;"Closed";"Not Yet"

See Access help regarding the Format property
+ formatting numbers and currency datatypes.

--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.
"Dave Hitt" <Bo****************@nycap.rr.com> wrote in message
news:md********************************@4ax.com...
I'm trying to put a function into a query. I want to check the
logical field "closed." If it's true, I want to return a text value
of "Closed". If false, I want to return a text value of "Not Yet."

Here's the value in the query:

Expr1: IF([closed],"Closed","Not Yet")

It accepts it without an error message, but when I try to display it I
get the error message "Undefined Function IF in expression." I've
tried using an equal sign in front of the if, but the program strips
it as soon as you leave the cell. I've tried it with "closed"
unbracketed, with the database name included, with closed=0, and none
of them work.

What do I need to do to make this work?

Dave Hitt
----
Why smoking bans kill businesses
http://www.davehitt.com/april03/homebody.html



Nov 12 '05 #4

P: n/a
On Fri, 03 Oct 2003 23:28:15 GMT, "Fredg" <fg******@example.invalid>
wrote:
Dave,
There is a simpler way than trying to do this in the query.
(You've already been told about using IIf instead of If.)

Is the query going to be used as a report record source?
If so, and the field [Closed] is a Check box field, just let the query
show the actual check value of -1 or 0.

In the report, simply add the check box field to the report.
Set it's Format property to:
;"Closed";"Not Yet"

See Access help regarding the Format property
+ formatting numbers and currency datatypes.


Thanks everyone. I figured it was something trivial that I was
missing.

Dave Hitt
----
Why smoking bans kill businesses
http://www.davehitt.com/april03/homebody.html
Nov 12 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.