Autofilter Access 2003??

mjchristinaj

New member
Local time
Today, 23:26
Joined
Oct 10, 2011
Messages
7
In essence, what I need to do is a 'autofilter' like in Excel with Satellite Launches table.

What I am trying to do now is a QBFquery where the user selects what to filter, as AND statements. The field to filter comes from the 'Satellite Launches' table. Some fields are shown in the user form as combobox (Launcher, Vehicle...) , and some others are checkboxs like (APPLICATIONS: Broadband (yes/no), Broadcasting (yes/not, Military(yes/not)...)To know if the user is willing to filter by the application, I inserted a check box 'filter by application'(App).
The user may decide to filter by all those fields or just one or few, then, some fields can be 'null' if the user dont choose any from the checkbox or combobox. So, in my Query criteria, I need to say something like:

WHERE (([Satellite Launches].Launcher=[Forms]![QBF_Form_F]![Launcher] or [Forms]![QBF_Form_F]![Launcher] is null)
AND ([Satellite Launches].Vehicle=[Forms]![QBF_Form_F]![Vehicle] or [Forms]![QBF_Form_F]![Vehicle] is null)
AND ([Forms]![QBF_Form_F]![App]=false or ([Satellite Launches].Broadband AND [Forms]![QBF_Form_F]![Broadband]))
AND ([Forms]![QBF_Form_F]![App]=false or ([Satellite Launches].Broadcasting AND [Forms]![QBF_Form_F]![Broadcasting]))
AND ([Forms]![QBF_Form_F]![App]=false or ([Satellite Launches].Military AND [Forms]![QBF_Form_F]![Military]))


When I try that, I got the error saying that the query is too complex. the problem might be that I am doing a wrong user Form squeme, but I can not think of a different way to ask user the parameter to filter and use them in the query. In essence, what I need to do is a 'autofilter' like in Excel with Satellite Launches table. I read that in Access 2007 you have that choice, but I am using 2003. Any suggestion which does not include VBA is welcome (I havent VBA skills :( ).

Thank you for your help
 
Hi,

I haven't tested this, but I think using NZ in the query instead of the Or statements might work.

WHERE (([Satellite Launches].Launcher=Nz([Forms]![QBF_Form_F]![Launcher] ,"") AND ....
 
Hi, Thanks! It works when I type:

WHERE (([Satellite Launches].Launcher=Nz([Forms]![QBF_Form_F]![Launcher] ,[Satellite Launches].Launcher) AND ....

However, I found a new problem: if in the user form, I select a field to filter by mistake, and then I unselect it, it does not work, because it is not null anymore, but it is 0, so it does not filter the way I want. How can I fix that??

Hi,

I haven't tested this, but I think using NZ in the query instead of the Or statements might work.

WHERE (([Satellite Launches].Launcher=Nz([Forms]![QBF_Form_F]![Launcher] ,"") AND ....
 

Users who are viewing this thread

Back
Top Bottom