ApplyFilter Command

E

Eric

I have a button on my form that runs a query when you
click on it. There is a field on the Form called "part
number" and a field in the query that is also called "part
number". I want to type a line of Visual Basic code that
automatically filters the query based on the Part Number I
have typed in on the form record that is currently active
on my screen. This is what I have typed so far:

DoCmd.ApplyFilter ([Queries]![Main Calculations]![Part
Number] = [Forms]![Remove]![Part Number].CurrentRecord)

This doesn't work. I know I'm really close--it's just a
matter of changing some brackets or adding periods or
something. I've done it once before but I can't remember
what exactly I'm supposed to type. Can anyone help?

Thanks!
 
G

Graham Mandeno

Hi Eric

Try this:

Me.Filter = "[Part Number]=" & [Part Number]
Me.FilterOn = True

You could make it a toggle button instead of a command button, and use it to
turn the filter on and off. To turn it off, just say:
Me.FilterOn = False

--
Good Luck!
Graham Mandeno [Access MVP]
Auckland, New Zealand

Return mail address is invalid in a vain attempt to reduce spam.
Feedback is welcome at: (e-mail address removed)
Please post new questions or followups to newsgroup.
 

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