How to filter a subform

L

Leslie Isaacs

Hello All

I have a subform that opens in datasheet view on a main form
There is a 'Find' button, with an unbound text box, on the main form.
I want the found button, when clicked, to filter the subform data such that
only those records where the field [presc_patient] contains the string
entered in the text box.
I also need another button (to be labelled "Show All") that will remove the
filter.

The main form is called [frm prescriptions main]
The subform is called [Child0]: its data source is [frm prescriptions
detail]
The unbound text box on the main form is called [findwhat].

The code that I have behind the 'Find' button on the main form is:

Private Sub Command12_Click()
[Forms]![frm prescriptions main].[Child0].frm.Filter = "[presc_patient] =
""*""& [forms]![frm prescriptions main].[findwhat] & ""*"" "
[Forms]![frm prescriptions main].[Child0].frm.FilterOn = True
End Sub

.... but it doesn't work. I get:
Runtime Error 438
Object doesn't support this property or method.

I have tried replacing the .frm.Filter with just .Filter, and I have tried
replacing [Child0] with [frm prescriptions detail], and I have tried single
quote marks round the *s, but it still didn't work!

Hope someone can help.
Many thanks.
Les
 

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