Filter isn't working, but same query does - Help?

  • Thread starter Thread starter Tim
  • Start date Start date
T

Tim

I have a query that Pulls 5 separate tables together.

Table A has the major portion of data, and the Primary Key = to all
the other Primary Keys.

I bring 2 field from each of tables B, C, D, & E.
Then I define the criteria of fields in B, C, & D that they must >
field E.

This is working and I can, I can base my form on it.
HOWEVER... I don't want to base my form on it. I want my form
unrestricted, and only apply this restriction (filter?) by pressing a
command button.

I've tried: DoCmd ApplyFilter FieldB>FieldE Or FieldC>FieldE....etc.
I get nothing from this. It appears to run and I have no errors, but
get no filter. I've tried brackets, parethesis, etc. Nothing.

I'm at the point after several different methods of cheating and just
having my command button close the form and open a new form based on
the working query, but that seems pretty cheap, and I'm hoping to
avoid it.

Help? Thanks!
Tim
 
Tim,

As far as I know, the ApplyFilter method doesn't work like that. You
will need...
DoCmd.ApplyFilter "NameOfYourQuery"
 
Steve Schapel said:
Tim,

As far as I know, the ApplyFilter method doesn't work like that. You
will need...
DoCmd.ApplyFilter "NameOfYourQuery"

Or else

DoCmd ApplyFilter , "FieldB>FieldE Or FieldC>FieldE ..."

That's a string literal, enclosed in quotes, that is the WHERE clause
(without the WHERE keyword) of your query. To use this form, there must
be a comma between ApplyFilter and the where-condition literal.
 
This was the solution that worked:

Private Sub cmd_Filter_Click()

me.Filter = "[FieldB] > [FieldE] OR [FieldC] > [FieldE] OR
[FieldD] >
[FieldE]"
me.FilterOn = Not me.FilterOn

end sub

The FilterOn.... using ApplyFilter... didn't do it. I still don't
really understand why... but I guess I'll have to leave it that way
for now. At least I'm working now.
 
Back
Top