Filter the sub form from main form

A

A1

thank you
I have form (master) and sub form
Question No (1)
How can i make ((Filter)) to the (((sub form only ))) Notes: I don't want
the master form included in the filter only sub form Filter
**** using command button in a main form ((master form))
Question No (2)
How can i apply a filter to the ((sub form)) after selecting the condition
in the sub form
**** using command button in a main form ((master form))
Question No (3)
How can I remove filter sort from the form
**** using command button in a main form ((master form))
 
A

A1

Dear Douglas J. Steel
Thank you
but this problem face me
when applying this code from parent form (master form ) to the sub form
this message appear
code in the command button on the master form (parent form)
Me!subformsearch.form.filter
this message appear:
 
D

Douglas J. Steele

To refer to the subform's filter from the Parent form, you'd use

Me!NameOfSubformControlOnParentForm.Form.Filter

Note that depending on how you added the form as a subform to the parent
form, the name of the subform control on the parent form may not be the same
as the name of the form being used as a subform. It's important that you use
the name of the subform control if they're different.

Similarly, to refer to a control on the subform from the Parent form, you'd
use

Me!NameOfSubformControlOnParentForm.Form!NameOfControlOnSubform

Once you know what the filter needs to be, you'd use:

Me!NameOfSubformControlOnParentForm.Form.Filter = strFilter
Me!NameOfSubformControlOnParentForm.Form.FilterOn = True

To turn it off, you'd us

Me!NameOfSubformControlOnParentForm.Form.FilterOn = False

(I usually reset the Filter to a zero-length string as well)

Incidentally, you appear to have asked this same question in more than one
newsgroup.

If you feel you need to post to more than one group (HINT: it's seldom
necessary), please have the courtesy to cross-post (send the one message to
all groups at once), rather than multi-post (send individual messages to
each group). In this way, all responses to your post will be available
together, regardless of what group the responder was in, and the rest of us
won't have to read your post multiple times. (It also uses fewer server
resources)

I see you're using Outlook Express. Click the "Newsgroups:" label to the
left of the box containing the name of the current newsgroup. That will open
a dialog that will let you add additional newsgroups to your post.
Note that it's generally consider to be A Bad Thing to cross-post to more
than about 2 or 3 newsgroups.
 
D

Douglas J. Steele

For point 1, if all you had was

Me!subformsearch.form.filter

then yes, you'd get an error. Filter is a property. You need either to
assign it a value, or assign its value to a variable.

For point 2, my suggestion assumed that you would be declaring a variable
strFilter (as a string), and then assigning the actual filter you wanted to
that variabl:

Dim strFilter As String

strFilter = "Id = " & Me!subsearchform.Form!SomeField
Me!subsearchform.Form.Filter=strFilter
Me!subformsearch.Form.FilterOn= True
 
A

A1

thank you
please can you give me example for point 1
This code i will put it in command button in parent form (master form) to
filter sub form
 
D

Douglas J. Steele

An example of what? I have no idea why you were referring to the property,
so I don't know what kind of example you're looking for!
 

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