applying a filter to a subform

G

Guest

Help! I have a Main form that is unbound with a subform bound to a query. The subform has option groups that fire filters on the data within the subform. If I run the subform on its own (not within the Main form), it works great. I used DoCmd.ApplyFilter...no problem. If I try to run the filtering when accessed through the Main form, I error out with a message telling me that the method is invalid due to the fact that the form is unbound. Why isn't the filter working normally and what do I need to do to make that happen?
 
A

Allen Browne

Try setting the Filter and FilterOn properties of the subform control.

Example:
Dim strFilter As String

strFilter = "ID = " & Me.SomeControl
With Me.[NameOfYourSubformControlHere].Form
.Filter = strFilter
.FilterOn = True
End With

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Mitch said:
Help! I have a Main form that is unbound with a subform bound to a query.
The subform has option groups that fire filters on the data within the
subform. If I run the subform on its own (not within the Main form), it
works great. I used DoCmd.ApplyFilter...no problem. If I try to run the
filtering when accessed through the Main form, I error out with a message
telling me that the method is invalid due to the fact that the form is
unbound. Why isn't the filter working normally and what do I need to do to
make that happen?
 
G

Guest

Gracias...Yer the bes

----- Allen Browne wrote: ----

Try setting the Filter and FilterOn properties of the subform control

Example
Dim strFilter As Strin

strFilter = "ID = " & Me.SomeContro
With Me.[NameOfYourSubformControlHere].For
.Filter = strFilte
.FilterOn = Tru
End Wit

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.htm
Reply to group, rather than allenbrowne at mvps dot org

Mitch said:
Help! I have a Main form that is unbound with a subform bound to a query
The subform has option groups that fire filters on the data within th
subform. If I run the subform on its own (not within the Main form), i
works great. I used DoCmd.ApplyFilter...no problem. If I try to run th
filtering when accessed through the Main form, I error out with a messag
telling me that the method is invalid due to the fact that the form i
unbound. Why isn't the filter working normally and what do I need to do t
make that happen
 

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