Subform filtering

L

Leslie Isaacs

Hello All

I have a subform [frm details] that opens in datasheet view on a main form
[frm main].

The subform has a field called [patient] and another field called [doctor].

The main form has an unbound text box called [findpatientordoctor].

I want to have a button on the main form that, when clicked, will filter the
subform data such that only records that contain the [findpatientordoctor]
string either in the field [patient] or in the field [doctor] are displayed.
I also need another button (to be labelled "Show All") that will remove the
filter.

I have tried to come up with the correct code, but cannot get it right: hope
someone can help.

Many thanks
Leslie Isaacs
 
T

t t via AccessMonster.com

Hello,

filtering

forms![frm main].[frm sub].frm.filter="[patient] = forms!frmmain.[text1] or
[doctor] = forms!frmmain.[text1]"

forms![frm main].[frm sub].frm.filteron=true



show all button

forms![frm main].[frm sub].frm.filteron=false

hope to help
 
L

Leslie Isaacs

Hello 't t'

Thanks for your reply.
Unfortunately I cannot get the code to work.
In fact the names of the forms are different from those in my origival post:

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

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

[Forms]![frm prescriptions main].[Child0].frm.Filter = "[presc_patient] =
[forms]![frm prescriptions main].[findwhat] "
[Forms]![frm prescriptions main].[Child0].frm.FilterOn = True

.... 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], but it still didn't
work.

Hope you 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