467,081 Members | 1,228 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,081 developers. It's quick & easy.

Filtering a subform

Hi,

I've been told in another forum that I can apply a filter to a subform (from
a control on the main form) by using the following code:

Me.sfrMySubform.Filter = "[intMyField] = 7"

I've tried this solution but it isn't working for me. Here's my code:

Private Sub fraShowRows_Click()
Select Case Me.fraShowRows
Case 1 'Available
Me.fsubAutoParts.Filter = "fldRemoved = False"
Case 2 'Sold
Me.fsubAutoParts.Filter = "fldRemovedReason = 'Sold'"
Case 3 'Lost/Stolen
Me.fsubAutoParts.Filter = "fldRemovedReason = 'Lost/Stolen'"
Case 4 'All
Me.fsubAutoParts.Filter = ""
End Select
End Sub

----------
fraShowRows is an option group with four choices which the user clicks to
indicate which records they wish to view.
----------

When I click on any of the options in fraShowRows, I receive the following:

Compile error
Method or Data Member not found

The name of the subform is highlighted in my code after I click OK on the
error message.

I've come across something similar when trying to apply changes to a subform
from the main form in the past. These were solved by replacing the form
name of the subform (fsubAutoParts) with the control name of the subform
"[Auto Parts]" (without quotes) on the main form. The code now looks like
this:

Private Sub fraShowRows_Click()
Select Case Me.fraShowRows
Case 1 'Available
Me.[Auto Parts].Filter = "fldRemoved = False"
Case 2 'Sold
Me.[Auto Parts].Filter = "fldRemovedReason = 'Sold'"
Case 3 'Lost/Stolen
Me.[Auto Parts].Filter = "fldRemovedReason = 'Lost/Stolen'"
Case 4 'All
Me.[Auto Parts].Filter = ""
End Select
End Sub

Now I receive the same error:

Compile Error
Method or data member not found

but now the .Filter method is highlighted in my code.

I've done everything I know to do and still can't get this to work. Can
anyone offer any suggestions?

Thanks!
Todd

Nov 13 '05 #1
  • viewed: 2127
Share:
3 Replies
Todd" <to**********@penland.net> wrote in message
news:Cu***************@fe25.usenetserver.com...
Hi,

I've been told in another forum that I can apply a filter to a subform (from
a control on the main form) by using the following code:

Me.sfrMySubform.Filter = "[intMyField] = 7"


Try...

Me.SubFormControlName.Form.Filter = "[intMyField] = 7"
Me.SubFormControlName.Form.FilterOn = True

Notice that you refeerence the name of the subform *control* which might not be
the same as the name of the form within it.
--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com
Nov 13 '05 #2
Todd, you need to use the subforms form object to use its Filter
property. Like...

Me.sfrMySubform.Form.Filter = "[intMyField] = 7"

Add that to your code and see how it works.

- Jim

On Sat, 31 Jul 2004 14:47:13 -0700, "Todd" <to**********@penland.net>
wrote:
Hi,

I've been told in another forum that I can apply a filter to a subform (from
a control on the main form) by using the following code:

Me.sfrMySubform.Filter = "[intMyField] = 7"

I've tried this solution but it isn't working for me. Here's my code:

Private Sub fraShowRows_Click()
Select Case Me.fraShowRows
Case 1 'Available
Me.fsubAutoParts.Filter = "fldRemoved = False"
Case 2 'Sold
Me.fsubAutoParts.Filter = "fldRemovedReason = 'Sold'"
Case 3 'Lost/Stolen
Me.fsubAutoParts.Filter = "fldRemovedReason = 'Lost/Stolen'"
Case 4 'All
Me.fsubAutoParts.Filter = ""
End Select
End Sub

----------
fraShowRows is an option group with four choices which the user clicks to
indicate which records they wish to view.
----------

When I click on any of the options in fraShowRows, I receive the following:

Compile error
Method or Data Member not found

The name of the subform is highlighted in my code after I click OK on the
error message.

I've come across something similar when trying to apply changes to a subform
from the main form in the past. These were solved by replacing the form
name of the subform (fsubAutoParts) with the control name of the subform
"[Auto Parts]" (without quotes) on the main form. The code now looks like
this:

Private Sub fraShowRows_Click()
Select Case Me.fraShowRows
Case 1 'Available
Me.[Auto Parts].Filter = "fldRemoved = False"
Case 2 'Sold
Me.[Auto Parts].Filter = "fldRemovedReason = 'Sold'"
Case 3 'Lost/Stolen
Me.[Auto Parts].Filter = "fldRemovedReason = 'Lost/Stolen'"
Case 4 'All
Me.[Auto Parts].Filter = ""
End Select
End Sub

Now I receive the same error:

Compile Error
Method or data member not found

but now the .Filter method is highlighted in my code.

I've done everything I know to do and still can't get this to work. Can
anyone offer any suggestions?

Thanks!
Todd


Nov 13 '05 #3
Thank you - that did it. I appreciate the help.

"Rick Brandt" <ri*********@hotmail.com> wrote in message
news:2n************@uni-berlin.de...
Todd" <to**********@penland.net> wrote in message
news:Cu***************@fe25.usenetserver.com...
Hi,

I've been told in another forum that I can apply a filter to a subform (from a control on the main form) by using the following code:

Me.sfrMySubform.Filter = "[intMyField] = 7"

Try...

Me.SubFormControlName.Form.Filter = "[intMyField] = 7"
Me.SubFormControlName.Form.FilterOn = True

Notice that you refeerence the name of the subform *control* which might

not be the same as the name of the form within it.
--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com


Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Damon Grieves | last post: by
2 posts views Thread by Katie | last post: by
3 posts views Thread by paquer@gmail.com | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.