title: MS Query with various multiple value parameters where there can be an empty parameter
body: <p>I have 5 multiple select listboxes in Excel. The selected content of every listbox is each written in one cell, separated with a comma.</p>
  
  <p>For example in cell A1 all the selected names: Tim, Miranda, Laura</p>
  
  <p>Those cells are the criteria for an Access query (where clause).</p>
  
  <p>I open MS Query and add the following where clause to the query and define the parameters:</p>
  
  <pre><code>Where (Instr(?, [name])&gt;0 And Instr(?, [number])&gt;0 And Instr(?, [city])&gt;0 And Instr(?, [phone])&gt;0 And Instr(?, [email])&gt;0) 
  </code></pre>
  
  <p>It works quite well, however <strong>if one of the parameter fields is empty</strong> (for example the user didn't select any city) <strong>the query returns all lines</strong>, where city is empty instead of ignoring that clause in this case.</p>
  
  <p>How do I solve this? Perhaps there is another solution using VBA and dynamic SQL.</p>
  
  <p>Note: I have to use Excel for the listboxes instead of Access formulas because the tool shall also be used by persons who do not have access to the database.</p>