Recordset.filter error

  • Thread starter Thread starter Jim Z.
  • Start date Start date
J

Jim Z.

I have a VBA Event code which executes when a form loads.
It attempts to limit a recordset of all employees to a
particular employee.

When it runs, I receive an run time error 2001 "You
already canceled this step". The VBEditor
highlights "Me.FilterOn = True".

When I pull up the Properties within the VB Editor, it
appears the default FilterOn is False. Any suggestions?

Me.RecordSource = "QryEmployeeID"
Me.Filter = "EmployeeID = 3"
Me.FilterOn = True

Thanks.
 
Rather than using VBA code to critique the data, why not
use a Select Query?

1. Create your Query listing the fields you want to
display.
2. In the Query EmployeeID field, set the criteria to
something like "Like Forms![MasterForm]![EmployeeID]" (do
not include the inverted commas!!!).
3. Name the Query "FilteredEmployeeDetails".
4. On the Form that you are trying to control the filter
on, remove the VBA Code that you have featured, then set
the Data Source to "FilteredEmployeeDetails".

This suggestion is based on the assumption that you are
trying to display records based on another Forms current
Record!!

HTH


Tony C.
 
Back
Top