Apply Filter

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!
 
T

tina

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
 
K

Ken Snell

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!
.
 

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