ApplyFilter Method Error

  • Thread starter Thread starter tim.leach
  • Start date Start date
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
 
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.
 
Back
Top