473,406 Members | 2,867 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Filter records in a subform control? (A97)

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
4 2712
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Tony Williams | last post by:
Sorry to repost but I cannot work this out. Can anyone come up with a suggestion? I have a main form based on Table1. The form has a tab control of three pages. Each page has a subform based on a...
14
by: Nothing | last post by:
I have a form that has a Tab Control on it. On one of the tab control pages, there are only 3 pages, is a combo box based on a field called departments in a table. When the user selects one of...
2
by: cefrancke | last post by:
I have a form (no underlying record set) that has two separate sub-forms on it. Each sub-form has data from two different tables. Above each sub-form there is one unbound combo box with a SQL...
2
by: Lenin Torres | last post by:
Hi everybody I have an Union Query that works fine. I used this query as the RecordSource for a Form. That Form is used as a subform in another form. Everything works fine, except for the "Filter...
3
by: dhowell | last post by:
In reading some of the posts on this group, it appears as though it is not strait forward at all to filter a form, which has subforms, by criteria which are either on subforms or span more than one...
7
by: Katherine | last post by:
I'm trying to filter the records on the mainform (MailingList) of my database using a field contained in a subform (Donations). I was basing my code off Allen Browne's Access Tips page (here:...
2
by: Matthew Wells | last post by:
Hi there. I am a programmer for a living, but this problem has my whole team stumped. I have a subform based on a query. I'm not using the "LinkMaster/ChildFields" properties ( I have my...
0
by: diogenes | last post by:
"Rick Brandt" <rickbrandt2@hotmail.comwrote in news:bPnKj.456$%41.325 @nlpi064.nbdc.sbc.com: I used this approach, and it works a treat! ID In(SELECT Order_ID FROM orderitems WHERE NAME =...
1
by: woodey2002 | last post by:
Hi Everyone and many thanks for your time.. I am trying to begin access and a bit of VBA i am enjoying it but I have a annoying problem I just can’t get any where on. My databse mostly includes...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.