Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old September 6th, 2008, 02:55 AM
MLH
Guest
 
Posts: n/a
Default Filter records in a subform control? (A97)

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.
  #2  
Old September 6th, 2008, 03:35 AM
MLH
Guest
 
Posts: n/a
Default Re: Filter records in a subform control? (A97)

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?
  #3  
Old September 6th, 2008, 04:05 AM
MLH
Guest
 
Posts: n/a
Default Re: Filter records in a subform control? (A97)

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.
  #4  
Old September 6th, 2008, 04:25 AM
MLH
Guest
 
Posts: n/a
Default Re: Filter records in a subform control? (A97)

<snip>
Quote:
>
>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

  #5  
Old September 6th, 2008, 01:35 PM
Rick Brandt
Guest
 
Posts: n/a
Default Re: Filter records in a subform control? (A97)

MLH wrote:
Quote:
<snip>
>
Quote:
>>
>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


 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles