A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

checkbox as query criteria



 
 
Thread Tools Display Modes
  #1  
Old May 1st, 2010, 01:55 PM posted to microsoft.public.access
remigio
external usenet poster
 
Posts: 6
Default checkbox as query criteria

Hi,
in an Access form i've put a combo box that has a query as data
source. On this form I'd like to add a check box that, when it is
selected, adds the "is not null" criteria on a query field.
There is a simple way to do this?
Thank you very much for help.

--

Remigio

www.sacraspina.it
www.amicitosondoro.it
www.icmonteodorisio.it
www.parrocchiacupello.it
www.cralnuovainiziativa.it
www.associazionehistonium.it
  #2  
Old May 1st, 2010, 02:04 PM posted to microsoft.public.access
Tom van Stiphout[_2_]
external usenet poster
 
Posts: 1,653
Default checkbox as query criteria

On Sat, 1 May 2010 05:55:14 -0700 (PDT), remigio
wrote:

Create two queries. Then switch between them based on your needs. For
example in the myCheckBox_AfterUpdate event you could write:
if me.myCheckbox.value = True then
Me.myCombobox.RowSource = "query2"
else
Me.myCombobox.RowSource = "query1"
end if
(of course you replace myObjectNames with yours)

-Tom.
Microsoft Access MVP


Hi,
in an Access form i've put a combo box that has a query as data
source. On this form I'd like to add a check box that, when it is
selected, adds the "is not null" criteria on a query field.
There is a simple way to do this?
Thank you very much for help.

  #3  
Old May 1st, 2010, 03:31 PM posted to microsoft.public.access
remigio
external usenet poster
 
Posts: 6
Default checkbox as query criteria

On 1 Mag, 15:04, Tom van Stiphout wrote:
On Sat, 1 May 2010 05:55:14 -0700 (PDT), remigio
wrote:

Create two queries. Then switch between them based on your needs. For
example in the myCheckBox_AfterUpdate event you could write:
if me.myCheckbox.value = True then
* Me.myCombobox.RowSource = "query2"
else
* Me.myCombobox.RowSource = "query1"
end if
(of course you replace myObjectNames with yours)

-Tom.
Microsoft Access MVP

Hi,
in an Access form i've put a combo box that has a query as data
source. On this form I'd like to add a check box that, when it is
selected, adds the "is not null" criteria on a query field.
There is a simple way to do this?
Thank you very much for help.


Thank you very much.

--

Remigio

www.sacraspina.it
www.amicitosondoro.it
www.icmonteodorisio.it
www.parrocchiacupello.it
www.cralnuovainiziativa.it
www.associazionehistonium.it
  #4  
Old May 1st, 2010, 05:39 PM posted to microsoft.public.access
KenSheridan via AccessMonster.com
external usenet poster
 
Posts: 1,610
Default checkbox as query criteria

Remigio:

You can in fact do it with a single query as the RowSource of the combo box,
e.g.

SELECT SomeField
FROM SomeTable
WHERE Form!YourCheckBox = FALSE
OR (Form!YourCheckBox = TRUE
AND SomeOtherField IS NOT NULL)
ORDER BY SomeField;

Note the use of the Form property to reference the current form rather than
referencing it as a member of the Forms collection.

This would return all rows from the table if the check box is not checked,
and only those where SomeOtherField contains a value if the check box is
checked. Be sure that the check box's default value is False by putting:

Me.YourCheckBox = False

in the form's Open event procedure. Otherwise it will be Null when the form
opens, until checked by the user. In the checkbox's AfterUpdate event
procedure requery the combo box:

Me.YourComboBox.Requery

Ken Sheridan
Stafford, England

remigio wrote:
Hi,
in an Access form i've put a combo box that has a query as data
source. On this form I'd like to add a check box that, when it is
selected, adds the "is not null" criteria on a query field.
There is a simple way to do this?
Thank you very much for help.

--

Remigio

www.sacraspina.it
www.amicitosondoro.it
www.icmonteodorisio.it
www.parrocchiacupello.it
www.cralnuovainiziativa.it
www.associazionehistonium.it


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/201005/1

  #5  
Old May 1st, 2010, 08:36 PM posted to microsoft.public.access
remigio
external usenet poster
 
Posts: 6
Default checkbox as query criteria

On 1 Mag, 18:39, "KenSheridan via AccessMonster.com" u51882@uwe
wrote:
Remigio:

You can in fact do it with a single query as the RowSource of the combo box,
e.g.

SELECT SomeField
FROM SomeTable
WHERE Form!YourCheckBox = FALSE
OR (Form!YourCheckBox = TRUE
AND SomeOtherField IS NOT NULL)
ORDER BY SomeField;

Note the use of the Form property to reference the current form rather than
referencing it as a member of the Forms collection.

This would return all rows from the table if the check box is not checked,
and only those where SomeOtherField contains a value if the check box is
checked. *Be sure that the check box's default value is False by putting:

Me.YourCheckBox = False

in the form's Open event procedure. *Otherwise it will be Null when the form
opens, until checked by the user. *In the checkbox's AfterUpdate event
procedure requery the combo box:

Me.YourComboBox.Requery

Ken Sheridan
Stafford, England



remigio wrote:
Hi,
in an Access form i've put a combo box that has a query as data
source. On this form I'd like to add a check box that, when it is
selected, adds the "is not null" criteria on a query field.
There is a simple way to do this?
Thank you very much for help.


--


Remigio


www.sacraspina.it
www.amicitosondoro.it
www.icmonteodorisio.it
www.parrocchiacupello.it
www.cralnuovainiziativa.it
www.associazionehistonium.it


--
Message posted via AccessMonster.comhttp://www.accessmonster.com/Uwe/Forums.aspx/access/201005/1


Thank you so much!
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 10:55 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.