ApplyFilter Method Error

T

tim.leach

I'm trying to use the ApplyFilter method in a VB event procedure. I
keep getting a runtime error. I'm not sure what I'm missing.

Runtime Error '2488'

You can't use the ApplyFilter action on this window.

blah
blah
blah

Use the SelectObject action or method to select the table, query, form
or report before applying the filter.*

*I thought that was what I was doing.

Any help is greatly appreciated. Here's my code:

Private Sub Command94_Click()

Dim tablename$
tablename = "Compare previous history - run 1"
DoCmd.OpenTable (tablename)
DoCmd.Maximize
DoCmd.SelectObject acTable, tablename,False
DoCmd.ApplyFilter , "[ACCOUNT NUMBER] = '123456789'"

End Sub

TIA
 
D

Duane Hookom

I'm not sure why you would do any of this. Normally, a developer would
create a form to display data records. Then write code to open the form to
display the data. You can add a where clause in the DoCmd.OpenForm method to
filter the results.
 

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