Need to apply second filter

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to apply 2 filters (or have 1 filter with 2 criterea). I tried:
DoCmd.ApplyFilter "", "[TagToDo]![GenerOpen]=True And
[TagToDo]![GenerClosed]=False"
and several variations but no joy.
 
What your filter tries to do is find records where some field is TRUE and
that same field is also FALSE. Obviously, there are no records that meet that
criterion because a field must be one or the other, and cannot be both.
If you wish to get records where the field is True *OR* the field is False,
you need to replace your AND with OR. If the field in question is indeed a
Yes/No type, then it may have up to three values: True, False or Null. If
your design disallows Nulls in this field, then there are only two possible
values, and the criterion = True OR = False is no filter at all, because it
will return all records.
 
1. I didn't mean to double post...the system told me there was a problem...

2. Your assertion I was looking for different values in the same field is
false. ServOpen = True and ServClosed = False.

Thanks for the try though.
 
Dirtbike said:
I need to apply 2 filters (or have 1 filter with 2 criterea). I tried:
DoCmd.ApplyFilter "", "[TagToDo]![GenerOpen]=True And
[TagToDo]![GenerClosed]=False"
and several variations but no joy.


You seem to be on the right track, but the syntax of your
table/field reference is invalid. It must be a dot instead
of bang. Actually, you should never have two fields with
the same name in a query so the table name is not needed.
You don't need to compare to True either.

Try using any of these:

"TagToDo.GenerOpen=True And TagToDo.GenerClosed=False"

"GenerOpen=True And GenerClosed=False"

"GenerOpen And Not GenerClosed"
 
I am not sure whether the empty String for FilterName affects your statement
or not but I never use the empty String to indicate no filter.

Personally, I also prefer to use parentheses to clearly specify the order of
operations, especially Boolean expressions on Boolean values.

DoCmd.ApplyFilter , "([GenerOpen]=True) And ([GenerClosed]=False)"
 
Still no joy. It askes to enter perameter value for GenerOpen

Marshall Barton said:
Dirtbike said:
I need to apply 2 filters (or have 1 filter with 2 criterea). I tried:
DoCmd.ApplyFilter "", "[TagToDo]![GenerOpen]=True And
[TagToDo]![GenerClosed]=False"
and several variations but no joy.


You seem to be on the right track, but the syntax of your
table/field reference is invalid. It must be a dot instead
of bang. Actually, you should never have two fields with
the same name in a query so the table name is not needed.
You don't need to compare to True either.

Try using any of these:

"TagToDo.GenerOpen=True And TagToDo.GenerClosed=False"

"GenerOpen=True And GenerClosed=False"

"GenerOpen And Not GenerClosed"
 
Still no joy. Sytem askes for perameter value for GenerClosed

Van T. Dinh said:
I am not sure whether the empty String for FilterName affects your statement
or not but I never use the empty String to indicate no filter.

Personally, I also prefer to use parentheses to clearly specify the order of
operations, especially Boolean expressions on Boolean values.

DoCmd.ApplyFilter , "([GenerOpen]=True) And ([GenerClosed]=False)"

--
HTH
Van T. Dinh
MVP (Access)




Dirtbike said:
I need to apply 2 filters (or have 1 filter with 2 criterea). I tried:
DoCmd.ApplyFilter "", "[TagToDo]![GenerOpen]=True And
[TagToDo]![GenerClosed]=False"
and several variations but no joy.
 
Still no joy. It askes to enter perameter value for GenerOpen

Does your Form's Recordsource query include fields named GenerOpen and
GenerClosed? The code assumes that it does.

John W. Vinson[MVP]
 
Well, um, that's a good question....I've got two tables with a 1-to-1....and
I see from the SQL that's driving the form that in fact GenerClosed is NOT!!!
So, you nailed it. You rock!
 

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

Back
Top