Query error if no value is selected in combobox form (1 Viewer)

fb110

New member
Local time
Today, 04:10
Joined
Dec 9, 2019
Messages
1
first thread , i'm new ....

Goal : created a report based on a query. Query is based on multiple combo boxes where one combobox is updating another based on the selected value. Like : option 1 is depending on the selected truck. option 2 is based on option 1 and so on ..... that works.

In order to create a report based on all selected options, i'm trying to create a query. results of this query will feed the report.

It's not the purpose that all combo boxes have a selection and here is the problem**************

when one of the comboboxes have no selection, the query gives not a single result ( because of null value )

i'm able to change a null value into a empty value but then the query gives all possible results and this is no option.

combo boxes are from x multiple tables / queries

What i want is that the query neglect a combo box and move to the next combobox of the query if no selction is made.

final result should be a query output only with the comboboxes that have a value set / selection made ....
 

Attachments

  • form.jpg
    form.jpg
    105.5 KB · Views: 74
  • query code to go empty.jpg
    query code to go empty.jpg
    11.4 KB · Views: 74
  • query empty.jpg
    query empty.jpg
    78.3 KB · Views: 73
  • query null.jpg
    query null.jpg
    40.9 KB · Views: 77
  • query.jpg
    query.jpg
    98.2 KB · Views: 71
Last edited:

vba_php

Forum Troll
Local time
Yesterday, 21:10
Joined
Oct 6, 2019
Messages
2,880
ok fb,

what you need here I'm thinking is something i wrote a FAQ on years ago. in order for a query to ignore an input parameter like a combo value if it is null, you have to write sql like this:
Code:
WHERE [field] = forms!frm_parameters![forks cb] OR 
forms!frm_parameters![forks cb] IS NULL
and then I believe if you want this evaluation by the query to take place on multiple combo boxes, you need to separate those "OR" statements, like the one I just illustrated above, by the "AND" keyword.

also, try doing an advanced search here on keywords "query by combo" in the "thread title" argument under the username "ajetrumpet" and see if you can find that faq i wrote. by the way, consider changing your control name "forks cb" to something without a space in it. spaces make code and sql always hard to read. it's common for developer to use "_" instead of a space.
 

Users who are viewing this thread

Top Bottom