Apply Filter

  • Thread starter Thread starter Eric
  • Start date Start date
E

Eric

I have two actions in my Macro, which is activated when
someone presses a command button on my form. The first
is "OpenQuery", which works just fine. The second
is "ApplyFilter", and it is not working, probably because
I did something wrong in my WHERE clause. On the form,
there is a field called "part number". The user types in a
part number then clicks the command button, which opens
the query. I want to automatically filter the query to
display only the records that match the part number they
typed in the current record. Currently, my WHERE clause
reads as follows:
[queryname]![Part Number]=[Forms]![formname]![Part
Number].CurrentRecord

I've tried a lot of different variations on this, none of
which have worked. So what am I doing wrong?

Thanks for the help!
 
if you read up on the ApplyFilter macro action in Help,
you'll notice it says you can use this action to apply a
filter to "a table, form, or report". it doesn't say you
can apply a filter to an opened query.

that's not proof that it's impossible, of course :)
but it would be easier just to open the query in design
view and set a criteria for the Part Number field, as
[Forms]![formname]![Part Number]

save the modified query. then change your macro to one
action: OpenQuery

hth
 
As tina notes, you can not filter a query using ApplyFilter. That action is
for a form. You must filter the query before you run it.

--
Ken Snell
<MS ACCESS MVP>

tina said:
if you read up on the ApplyFilter macro action in Help,
you'll notice it says you can use this action to apply a
filter to "a table, form, or report". it doesn't say you
can apply a filter to an opened query.

that's not proof that it's impossible, of course :)
but it would be easier just to open the query in design
view and set a criteria for the Part Number field, as
[Forms]![formname]![Part Number]

save the modified query. then change your macro to one
action: OpenQuery

hth
-----Original Message-----
I have two actions in my Macro, which is activated when
someone presses a command button on my form. The first
is "OpenQuery", which works just fine. The second
is "ApplyFilter", and it is not working, probably because
I did something wrong in my WHERE clause. On the form,
there is a field called "part number". The user types in a
part number then clicks the command button, which opens
the query. I want to automatically filter the query to
display only the records that match the part number they
typed in the current record. Currently, my WHERE clause
reads as follows:
[queryname]![Part Number]=[Forms]![formname]![Part
Number].CurrentRecord

I've tried a lot of different variations on this, none of
which have worked. So what am I doing wrong?

Thanks for the help!
.
 
Back
Top