Hi All,
How do I filter data on a subform by using a macro?
I have a form named "Directory" and within that a subform named, "Advisors". I want to filter the 'City' field, for an example.
I have created a macro (Where Condition: [Forms]![Directory]![Advisors].[Form]![City] Like "Toronto"
, which is run by a Command buttons click event (Docmd.ApplyFilter "xxxx"
. This Command button is on my subform not on the main form. It works fine when I just open the subform and run the macro. But when the subform is opened through the main form, it gives me the following error:
"Run-time error '2491':
The action or method is invalid because the form or report isn't bound to a table or query.
You tired to use the ApplyFilter action or method. However, the form or report you applied the filter to is not based on a table or query, so the form or report doesn't have any records to apply a filter to. …"
Can someone please help! ? :-(
How do I filter data on a subform by using a macro?
I have a form named "Directory" and within that a subform named, "Advisors". I want to filter the 'City' field, for an example.
I have created a macro (Where Condition: [Forms]![Directory]![Advisors].[Form]![City] Like "Toronto"
"Run-time error '2491':
The action or method is invalid because the form or report isn't bound to a table or query.
You tired to use the ApplyFilter action or method. However, the form or report you applied the filter to is not based on a table or query, so the form or report doesn't have any records to apply a filter to. …"
Can someone please help! ? :-(