Recordset.filter error

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

Tony C

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.
 

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