View Single Post
  #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