MS Access query to toggle between records with true and all records -


i have query returns, among other things, active flag: true active, false not active. there active checkbox control on form. default checked. when checkbox checked need query return records active = true. when checkbox not checked, need records returned.

i have been trying set criteria on active field in query this:

iif([forms]![myform]![chkactive]=true,true,) iif([forms]![myform]![chkactive]=true,true, true or false) iif([forms]![myform]![chkactive]=true,true,([myquery]![active])=true or ([myquery]![active])=false) 

the reasoning if chkactive checked, iif returns true , otherwise returns indication want records. checked part seems work fine. , if use like:

iif([forms]![myform]![chkactive]=true,true,false) 

i can switch between seeing true records , false records. switch between seeing true records , records.

the other thing query returns nothing when form opens. think value of [forms]![myform]![chkactive] not exist @ time when query needed populate form. however, query seems access [forms]![myform]![chkactive] fine when called onclick event of chkactive. gets called by:

docmd.requery 

any useful insight appreciated.

add value of control column inside query:

filtercontrol1: [forms]![myform]![chkactive] 

and set criteria column in ([active], false).
expression true if either control , column match or if false selected. false works all selector.
may bit cryptical, works other data types. have combobox ids , added id = -1, text ='<all>' union in query.
columnn: [controlname], criteria: in ([column], -1) works alike filter either selection or -1 all.

i can confirm filter not work on loading. guess that's access. me.requery in form_load seems work ok.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -