473,385 Members | 2,003 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Choose Function

Can the Choose function be used to set the criteria for a field in a query
to either "Is Null" or "Is Not Null" based on the value of an option Group
on a form? Such as:
Choose(Forms!MyForm!MyOptionGroup,Is Null,Is Not Null)
Where MyOptionGroup can have the value of 1 or 2.

Thanks!
May 15 '06 #1
12 2886
No it can't. You'll have to set your query up another way.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
"Steve" <No****@Spam.Com> wrote in message
news:v8**************@newsread3.news.pas.earthlink .net...
Can the Choose function be used to set the criteria for a field in a query
to either "Is Null" or "Is Not Null" based on the value of an option Group
on a form? Such as:
Choose(Forms!MyForm!MyOptionGroup,Is Null,Is Not Null)
Where MyOptionGroup can have the value of 1 or 2.

Thanks!

May 15 '06 #2
Thanks, Doug!

I can get the Is Not Null part in the below but can not get the Is Null
part. Do you have any ideas?

Choose(Forms!MyForm!MyOptionGroup,Is Null,[MyField])

Steve
"Douglas J Steele" <NOSPAM_djsteele@NOSPAM_canada.com> wrote in message
news:e3*************@TK2MSFTNGP02.phx.gbl...
No it can't. You'll have to set your query up another way.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
"Steve" <No****@Spam.Com> wrote in message
news:v8**************@newsread3.news.pas.earthlink .net...
Can the Choose function be used to set the criteria for a field in a
query
to either "Is Null" or "Is Not Null" based on the value of an option
Group
on a form? Such as:
Choose(Forms!MyForm!MyOptionGroup,Is Null,Is Not Null)
Where MyOptionGroup can have the value of 1 or 2.

Thanks!


May 15 '06 #3
"PC Datasheet" <No****@Spam.Com> wrote in message
news:7i****************@newsread2.news.pas.earthli nk.net...
Thanks, Doug!

I can get the Is Not Null part in the below but can not get the Is Null
part. Do you have any ideas?

Choose(Forms!MyForm!MyOptionGroup,Is Null,[MyField])


There is no "Is Not Null part in the below", only "Is Null". What exactly
are you trying to achieve? Are you trying to return Null when MyOptionGroup
= 1 and whatever MyField is when MyOptionGroup = 2?

Keith.
www.keithwilby.com
May 15 '06 #4
Explain what you're trying to do in words, rather with a partial code
snippet...

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
"PC Datasheet" <No****@Spam.Com> wrote in message
news:7i****************@newsread2.news.pas.earthli nk.net...
Thanks, Doug!

I can get the Is Not Null part in the below but can not get the Is Null
part. Do you have any ideas?

Choose(Forms!MyForm!MyOptionGroup,Is Null,[MyField])

Steve
"Douglas J Steele" <NOSPAM_djsteele@NOSPAM_canada.com> wrote in message
news:e3*************@TK2MSFTNGP02.phx.gbl...
No it can't. You'll have to set your query up another way.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
"Steve" <No****@Spam.Com> wrote in message
news:v8**************@newsread3.news.pas.earthlink .net...
Can the Choose function be used to set the criteria for a field in a
query
to either "Is Null" or "Is Not Null" based on the value of an option
Group
on a form? Such as:
Choose(Forms!MyForm!MyOptionGroup,Is Null,Is Not Null)
Where MyOptionGroup can have the value of 1 or 2.

Thanks!



May 15 '06 #5
On Mon, 15 May 2006 13:24:19 GMT, "PC Datasheet" <No****@Spam.Com>
wrote:
Thanks, Doug!

I can get the Is Not Null part in the below but can not get the Is Null
part. Do you have any ideas?

Choose(Forms!MyForm!MyOptionGroup,Is Null,[MyField])

Steve


Steve, any function - IIF, Switch, Choose, etc. - can return a
*VALUE*. However it cannot return an *operator* such as IS NULL.

AFAIK the only way to get this to work would be to dispense with the
function altogether with a syntax like

WHERE (fieldname IS NULL AND Forms!MyForm!MyOptionGroup = 1)
OR (fieldname = [MyField] AND Forms!MyForm!MyOptionGroup = 2)
John W. Vinson[MVP]
May 15 '06 #6
I am not looking to query for a specific value. Suppose the field in the
query is InspectionDate. When the option group on the QBF form, MyForm, has
a value
of 1, I want to return all records where InspectionDate is null. When the
option group on the QBF form, MyForm, has a value of 2, I want to return all
records
where InspectionDate is not null. And actually in my problem, when the
option group on the QBF form, MyForm, has a value of 3, I want to return all
records.

Steve

"Douglas J Steele" <NOSPAM_djsteele@NOSPAM_canada.com> wrote in message
news:uX**************@TK2MSFTNGP05.phx.gbl...
Explain what you're trying to do in words, rather with a partial code
snippet...

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
"PC Datasheet" <No****@Spam.Com> wrote in message
news:7i****************@newsread2.news.pas.earthli nk.net...
Thanks, Doug!

I can get the Is Not Null part in the below but can not get the Is Null
part. Do you have any ideas?

Choose(Forms!MyForm!MyOptionGroup,Is Null,[MyField])

Steve
"Douglas J Steele" <NOSPAM_djsteele@NOSPAM_canada.com> wrote in message
news:e3*************@TK2MSFTNGP02.phx.gbl...
> No it can't. You'll have to set your query up another way.
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no e-mails, please!)
>
>
> "Steve" <No****@Spam.Com> wrote in message
> news:v8**************@newsread3.news.pas.earthlink .net...
>> Can the Choose function be used to set the criteria for a field in a
>> query
>> to either "Is Null" or "Is Not Null" based on the value of an option
>> Group
>> on a form? Such as:
>> Choose(Forms!MyForm!MyOptionGroup,Is Null,Is Not Null)
>> Where MyOptionGroup can have the value of 1 or 2.
>>
>> Thanks!
>>
>>
>
>



May 15 '06 #7
The "Is Not Null part in the below" is [MyField], the third parameter in the
Choose function. If the Option Group value is 2, [MyField] in the third
parameter will cause the query to return all records where [MyField] is not
null.

For a full explanation of my problem, see my reply back to Doug Steele.

Steve
"Keith Wilby" <he**@there.com> wrote in message
news:44**********@glkas0286.greenlnk.net...
"PC Datasheet" <No****@Spam.Com> wrote in message
news:7i****************@newsread2.news.pas.earthli nk.net...
Thanks, Doug!

I can get the Is Not Null part in the below but can not get the Is Null
part. Do you have any ideas?

Choose(Forms!MyForm!MyOptionGroup,Is Null,[MyField])


There is no "Is Not Null part in the below", only "Is Null". What exactly
are you trying to achieve? Are you trying to return Null when
MyOptionGroup = 1 and whatever MyField is when MyOptionGroup = 2?

Keith.
www.keithwilby.com

May 15 '06 #8
John,

Thank you for responding!

I am not looking to query for a specific value. Suppose the field in the
query is InspectionDate. When the option group on the QBF form, MyForm, has
a value of 1, I want to return all records where InspectionDate is null.
When the option group on the QBF form, MyForm, has a value of 2, I want to
return all records where InspectionDate is not null. And actually in my
problem, when the option group on the QBF form, MyForm, has a value of 3, I
want to return all records.

Using the following expression in the criteria of the InspectionDate field
in the query,
Choose(Forms!MyForm!MyOptionGroup,Is Null,[InspectionDate])
when the Option Group value is 2, [InspectionDate] in the third parameter
will cause the query to return all records where [InspectionDate] is not
null. That's half the solution. I am looking for something to put in the
second parameter of the Choose function so when the Option Group value is 1,
it will cause the query to return all records where [InspectionDate] is
null.

Steve


"John Vinson" <jvinson@STOP_SPAM.WysardOfInfo.com> wrote in message
news:f8********************************@4ax.com...
On Mon, 15 May 2006 13:24:19 GMT, "PC Datasheet" <No****@Spam.Com>
wrote:
Thanks, Doug!

I can get the Is Not Null part in the below but can not get the Is Null
part. Do you have any ideas?

Choose(Forms!MyForm!MyOptionGroup,Is Null,[MyField])

Steve


Steve, any function - IIF, Switch, Choose, etc. - can return a
*VALUE*. However it cannot return an *operator* such as IS NULL.

AFAIK the only way to get this to work would be to dispense with the
function altogether with a syntax like

WHERE (fieldname IS NULL AND Forms!MyForm!MyOptionGroup = 1)
OR (fieldname = [MyField] AND Forms!MyForm!MyOptionGroup = 2)
John W. Vinson[MVP]

May 15 '06 #9
WHERE (InspectionDate IS NULL AND Forms!MyForm!MyOptionGroup = 1)
OR (InspectionDate IS NOT NULL AND Forms!MyForm!MyOptionGroup = 2)
OR (Forms!MyForm!MyOptionGroup = 3)

Obviously if you've got other conditions, you'd have to wrap all of that in
parentheses, and then have the rest of the conditions:

WHERE ((InspectionDate IS NULL AND Forms!MyForm!MyOptionGroup = 1)
OR (InspectionDate IS NOT NULL AND Forms!MyForm!MyOptionGroup = 2)
OR (Forms!MyForm!MyOptionGroup = 3))
AND Field1 = "X"
AND Field2 = 1

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
"PC Datasheet" <No****@Spam.Com> wrote in message
news:nE****************@newsread3.news.pas.earthli nk.net...
I am not looking to query for a specific value. Suppose the field in the
query is InspectionDate. When the option group on the QBF form, MyForm, has a value
of 1, I want to return all records where InspectionDate is null. When the
option group on the QBF form, MyForm, has a value of 2, I want to return all records
where InspectionDate is not null. And actually in my problem, when the
option group on the QBF form, MyForm, has a value of 3, I want to return all records.

Steve

"Douglas J Steele" <NOSPAM_djsteele@NOSPAM_canada.com> wrote in message
news:uX**************@TK2MSFTNGP05.phx.gbl...
Explain what you're trying to do in words, rather with a partial code
snippet...

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
"PC Datasheet" <No****@Spam.Com> wrote in message
news:7i****************@newsread2.news.pas.earthli nk.net...
Thanks, Doug!

I can get the Is Not Null part in the below but can not get the Is Null
part. Do you have any ideas?

Choose(Forms!MyForm!MyOptionGroup,Is Null,[MyField])

Steve
"Douglas J Steele" <NOSPAM_djsteele@NOSPAM_canada.com> wrote in message
news:e3*************@TK2MSFTNGP02.phx.gbl...
> No it can't. You'll have to set your query up another way.
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no e-mails, please!)
>
>
> "Steve" <No****@Spam.Com> wrote in message
> news:v8**************@newsread3.news.pas.earthlink .net...
>> Can the Choose function be used to set the criteria for a field in a
>> query
>> to either "Is Null" or "Is Not Null" based on the value of an option
>> Group
>> on a form? Such as:
>> Choose(Forms!MyForm!MyOptionGroup,Is Null,Is Not Null)
>> Where MyOptionGroup can have the value of 1 or 2.
>>
>> Thanks!
>>
>>
>
>



May 15 '06 #10
John,

Got it to work; thought you might be interested ---

1. Added following field to query:
InspDate: NZ([InspectionDate],"InspectionDateIsNull")

2. Added following criteria to InspDate:
Choose([Forms]![PFrmFindOrderToCallToScheduleInspection]![InspectionDateSet],"InspectionDateIsNull",[InspectionDate],NZ([InspectionDate],"InspectionDateIsNull"))

** [InspectionDateSet] is the name of the option group.

When [InspectionDateSet] is 1, the query returns all records where
[InspectionDate] is null.

When [InspectionDateSet] is 2, the query returns all records where
[InspectionDate] is not null.

When [InspectionDateSet] is 3, the query returns all records.

Steve
"John Vinson" <jvinson@STOP_SPAM.WysardOfInfo.com> wrote in message
news:f8********************************@4ax.com...
On Mon, 15 May 2006 13:24:19 GMT, "PC Datasheet" <No****@Spam.Com>
wrote:
Thanks, Doug!

I can get the Is Not Null part in the below but can not get the Is Null
part. Do you have any ideas?

Choose(Forms!MyForm!MyOptionGroup,Is Null,[MyField])

Steve


Steve, any function - IIF, Switch, Choose, etc. - can return a
*VALUE*. However it cannot return an *operator* such as IS NULL.

AFAIK the only way to get this to work would be to dispense with the
function altogether with a syntax like

WHERE (fieldname IS NULL AND Forms!MyForm!MyOptionGroup = 1)
OR (fieldname = [MyField] AND Forms!MyForm!MyOptionGroup = 2)
John W. Vinson[MVP]

May 15 '06 #11
Doug,

Got it to work; thought you might be interested. See my reply back to John
Vinson for the solution.

Steve
"Douglas J Steele" <NOSPAM_djsteele@NOSPAM_canada.com> wrote in message
news:OI**************@TK2MSFTNGP02.phx.gbl...
WHERE (InspectionDate IS NULL AND Forms!MyForm!MyOptionGroup = 1)
OR (InspectionDate IS NOT NULL AND Forms!MyForm!MyOptionGroup = 2)
OR (Forms!MyForm!MyOptionGroup = 3)

Obviously if you've got other conditions, you'd have to wrap all of that
in
parentheses, and then have the rest of the conditions:

WHERE ((InspectionDate IS NULL AND Forms!MyForm!MyOptionGroup = 1)
OR (InspectionDate IS NOT NULL AND Forms!MyForm!MyOptionGroup = 2)
OR (Forms!MyForm!MyOptionGroup = 3))
AND Field1 = "X"
AND Field2 = 1

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
"PC Datasheet" <No****@Spam.Com> wrote in message
news:nE****************@newsread3.news.pas.earthli nk.net...
I am not looking to query for a specific value. Suppose the field in the
query is InspectionDate. When the option group on the QBF form, MyForm,

has
a value
of 1, I want to return all records where InspectionDate is null. When the
option group on the QBF form, MyForm, has a value of 2, I want to return

all
records
where InspectionDate is not null. And actually in my problem, when the
option group on the QBF form, MyForm, has a value of 3, I want to return

all
records.

Steve

"Douglas J Steele" <NOSPAM_djsteele@NOSPAM_canada.com> wrote in message
news:uX**************@TK2MSFTNGP05.phx.gbl...
> Explain what you're trying to do in words, rather with a partial code
> snippet...
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no e-mails, please!)
>
>
> "PC Datasheet" <No****@Spam.Com> wrote in message
> news:7i****************@newsread2.news.pas.earthli nk.net...
>> Thanks, Doug!
>>
>> I can get the Is Not Null part in the below but can not get the Is
>> Null
>> part. Do you have any ideas?
>>
>> Choose(Forms!MyForm!MyOptionGroup,Is Null,[MyField])
>>
>> Steve
>>
>>
>> "Douglas J Steele" <NOSPAM_djsteele@NOSPAM_canada.com> wrote in
>> message
>> news:e3*************@TK2MSFTNGP02.phx.gbl...
>> > No it can't. You'll have to set your query up another way.
>> >
>> > --
>> > Doug Steele, Microsoft Access MVP
>> > http://I.Am/DougSteele
>> > (no e-mails, please!)
>> >
>> >
>> > "Steve" <No****@Spam.Com> wrote in message
>> > news:v8**************@newsread3.news.pas.earthlink .net...
>> >> Can the Choose function be used to set the criteria for a field in
>> >> a
>> >> query
>> >> to either "Is Null" or "Is Not Null" based on the value of an
>> >> option
>> >> Group
>> >> on a form? Such as:
>> >> Choose(Forms!MyForm!MyOptionGroup,Is Null,Is Not Null)
>> >> Where MyOptionGroup can have the value of 1 or 2.
>> >>
>> >> Thanks!
>> >>
>> >>
>> >
>> >
>>
>>
>
>



May 15 '06 #12
Hi,

alternatively:

WHERE CHOOSE(
FORMS!pfrmFindOrderToVallToScheduleInspection!insp ectionDateSet,
InspDate Is Null,
Not InspDate Is Null,
true)
the idea being to get the whole expression evaluated inside the choose.
Vanderghast, Access MVP
"PC Datasheet" <No****@Spam.Com> wrote in message
news:hw****************@newsread1.news.pas.earthli nk.net...
John,

Got it to work; thought you might be interested ---

1. Added following field to query:
InspDate: NZ([InspectionDate],"InspectionDateIsNull")

2. Added following criteria to InspDate:
Choose([Forms]![PFrmFindOrderToCallToScheduleInspection]![InspectionDateSet],"InspectionDateIsNull",[InspectionDate],NZ([InspectionDate],"InspectionDateIsNull"))

** [InspectionDateSet] is the name of the option group.

When [InspectionDateSet] is 1, the query returns all records where
[InspectionDate] is null.

When [InspectionDateSet] is 2, the query returns all records where
[InspectionDate] is not null.

When [InspectionDateSet] is 3, the query returns all records.

Steve
"John Vinson" <jvinson@STOP_SPAM.WysardOfInfo.com> wrote in message
news:f8********************************@4ax.com...
On Mon, 15 May 2006 13:24:19 GMT, "PC Datasheet" <No****@Spam.Com>
wrote:
Thanks, Doug!

I can get the Is Not Null part in the below but can not get the Is Null
part. Do you have any ideas?

Choose(Forms!MyForm!MyOptionGroup,Is Null,[MyField])

Steve


Steve, any function - IIF, Switch, Choose, etc. - can return a
*VALUE*. However it cannot return an *operator* such as IS NULL.

AFAIK the only way to get this to work would be to dispense with the
function altogether with a syntax like

WHERE (fieldname IS NULL AND Forms!MyForm!MyOptionGroup = 1)
OR (fieldname = [MyField] AND Forms!MyForm!MyOptionGroup = 2)
John W. Vinson[MVP]


May 16 '06 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: kingofkolt | last post by:
I have a directory of images, called "random". In it are the following files: 1.gif 2.gif 3.gif 4.gif I use this script to choose a random image and display it:
6
by: Penny | last post by:
Hi all, I've built a simple search <Form> on a web page that is intended to allow the user to search a record store database. There is a drop down box where the user can choose either 'Artist'...
8
by: Nicole | last post by:
Hi I need to be able to change the currency and some form fields displayed on my website depending on where the visitor is based. I don't need a fully functional cart, just a kinda either...
3
by: Anders Borum | last post by:
Hello! I've come across a strange error that occurs, when you try to return a nodelist from a variable with a choose/where/otherwise statement. I'm not quite sure whether it's a bug or simply...
14
ADezii
by: ADezii | last post by:
The tendency of VBA code to evaluate all expressions, whether or not they need to be evaluated from a logical standpoint, makes the use of the IIf(), Switch(), and Choose() Functions inefficient and...
19
by: Coastie | last post by:
Good afternoon- There is a table with the following fields: PK*, Equipment_ID, Battery_Serial *= arbitrary primary key Each piece of equipment has between 0 and 3 batteries, and each battery...
5
by: alhomam | last post by:
hi all, i have a table that has the two fileds: Return Date, Extension Time for Return Date i need a query to choose the max date between these two fields eg: if return date = 01...
0
by: ARC | last post by:
Hello all, In my access 2007 app, I'm using the code for fonts/colors that I believe I found years ago on the accessweb.net site. Problem is, calling the color picker is opening the very old...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.