Opening a form with two filter criteria

  • Thread starter John Constantine
  • Start date
J

John Constantine

How do open a form that requires 2 filters


Say I have a form called “owners”
It has a field called “cars”
And a anoth field called “color”

I could go

Docmd.openform “owners”,,,”cars =’Honda’ “

To give me the all the Honda’s

But say I wanted all the “black” Hondas - how do I put the second
filter requirement in the above expression ?
 
B

Bernd Gilles

Am 06.07.2011 16:30, schrieb John Constantine:
I could go

Docmd.openform “owners”,,,”cars =’Honda’ “

To give me the all the Honda’s

But say I wanted all the “black” Hondas - how do I put the second
filter requirement in the above expression ?

very easy:
Docmd.openform “owners”,,,"cars = 'Honda' AND color = 'black'"

hth
 
J

John W. Vinson

How do open a form that requires 2 filters


Say I have a form called “owners”
It has a field called “cars”
And a anoth field called “color”

I could go

Docmd.openform “owners”,,,”cars =’Honda’ “

To give me the all the Honda’s

But say I wanted all the “black” Hondas - how do I put the second
filter requirement in the above expression ?

The WhereCondition argument is simply the WHERE clause from a Query without
the keyword "WHERE". You can create a query in the query grid, and view it as
SQL - embedded in it will be a clause like

.... WHERE [Cars] = 'Honda' AND [Color] = 'Black'...

You can copy or transcribe this clause into your code as the WhereCondition.
It can include one or more AND and OR clauses, expressions, even subqueries;
it takes a bit of skull sweat to figure out how to construct the clause from
scratch, but it's very logical and can be useful.
--

John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
http://social.msdn.microsoft.com/Forums/en-US/accessdev/
http://social.answers.microsoft.com/Forums/en-US/addbuz/
and see also http://www.utteraccess.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top