Quantcast
Viewing latest article 2
Browse Latest Browse All 7

Criteria in a Query

Curt,

Curt Ch wrote:

[Medium 1] is the field name of the table. 

Ok, we don't need it in the formula.

I am trying to ask the query
to show all records if the combo box on my form is empty.  Your formula
worked, except it only worked if I used it on one column of the query
(one field of the table).  I am trying to filter on 5 different fields
of the table. 

All you need to do is repeat the formula on the other 4 fields, while
changing the form reference to the relevant control name.

Table of cars

Make: Model: Year: Color: Horse Power:

You haven't shown your SQL statement, so I can only guess field names, same
for control names. Combo4 isn't a good name to use, you should change the
control names to speaking names, e.g.
  cboMake
  cboModel
  cboYear
  cboColor
  cboHorsePower

I assume Combo4 filters on Make and that you will follow my recommendation
to change the names. The SQL statement could look like that:

SELECT [Make], [Model], [Year], [Color], [Horse Power]
FROM [Table of Cars]
WHERE ( [Make] = [Forms]![Combined Board Report Form].[cboMake] Or
        [Forms]![Combined Board Report Form].[cboMake] Is Null )
AND   ( [Model] = [Forms]![Combined Board Report Form].[cboModel] Or
        [Forms]![Combined Board Report Form].[cboModel] Is Null )
AND   ( [Year] = [Forms]![Combined Board Report Form].[cboYear] Or
        [Forms]![Combined Board Report Form].[cboYear] Is Null )
AND   ( [Color] = [Forms]![Combined Board Report Form].[cboColor] Or
        [Forms]![Combined Board Report Form].[cboColor] Is Null )
AND   ( [Horse Power] =
        [Forms]![Combined Board Report Form].[cboHorsePower] Or
        [Forms]![Combined Board Report Form].[cboHorsePower] Is Null )

(aircode)

HTH


Peter Doering [MVP Access]


Viewing latest article 2
Browse Latest Browse All 7

Trending Articles