By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,825 Members | 2,437 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,825 IT Pros & Developers. It's quick & easy.

Filter records in a subform control? (A97)

P: n/a
MLH
If I have a main form - Form3 - with a subform control
named SF4 and they are NOT linked on any common
field (no child or master field links) - can I write code on
Form3 to filter the records displayed in the subform SF4?
I want to dynamically change the records displayed in
the subform control at the click of a button.
Sep 6 '08 #1
Share this Question
Share on Google+
4 Replies


P: n/a
MLH
To simplify things a bit, I'm trying my filter
in a simple form - no subforms. Am having
difficulty there. Here's A97's textbook example:

Me.Filter = "Country = 'USA'"
Me.FilterOn = True

That's not what I want

I'm trying to apply a filter with wildcard characters.
Take this, for example...

Me.Filter = "Country = '*AND*'"
Me.FilterOn = True

That way, instead of finding a country USA,
I could find any country with AND in its name -
Andorra, England, Finland, Iceland, Ireland,
Marshall Islands, The Netherlands, New Zealand,
etc...

I'm having trouble with that. Anybody have a
suggestion?
Sep 6 '08 #2

P: n/a
MLH
When I use something like the following, I get a runtime
error #2448 saying I cannot assign a value to the object.
Of course, it's talking about the Me.Filter assignment line.
Why is that, I wonder? Of course, we all know that you
CAN assign a value to the Filter property.

Private Sub Command4_Click()
MyString = "sch"
Me.Filter = "AllNames = Like '*" & GetMyString() & "*'"
Me.FilterOn = True
End Sub

Why is that, I wonder? Of course, we all know that you
CAN assign a value to the Filter property. So there's a
problem with the syntax of the filter I'm trying to assign.
Just can't figure it out.
Sep 6 '08 #3

P: n/a
MLH
<snip>
>
Private Sub Command4_Click()
MyString = "sch"
Me.Filter = "AllNames = Like '*" & GetMyString() & "*'"
Me.FilterOn = True
End Sub
<snip>

Well, the following syntax works in the private sub ...
MyString = "sch"
Me.Filter = "Query17.AllNames Like '*" & GetMyString() & "*'"
Me.FilterOn = True

Sep 6 '08 #4

P: n/a
MLH wrote:
<snip>
>>
Private Sub Command4_Click()
MyString = "sch"
Me.Filter = "AllNames = Like '*" & GetMyString() & "*'"
Me.FilterOn = True
End Sub
<snip>

Well, the following syntax works in the private sub ...
MyString = "sch"
Me.Filter = "Query17.AllNames Like '*" & GetMyString() & "*'"
Me.FilterOn = True
Did you notice that the first has both "=" and "Like"?

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Sep 6 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.