473,413 Members | 1,789 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,413 software developers and data experts.

Cascaded Form Filtering with Subforms

I need to use unbound controls in a form header to filter a form. There is a very well written insight that describes filtering forms with unbound controls in the form header. (http://bytes.com/topic/access/insigh...form-filtering) However, it clearly states that the example is simple and does not include subforms. My form has two subforms each with a single combo box control. I need to filter records in my form based on values in my subforms and I need them to cascade. Help?
Dec 8 '11 #1

✓ answered by NeoPa

So, each project can be related to multiple rivers, as well as multiple communities, and also multiple projects can be related to any of these same rivers or communities. Nice. In that case the filter string for the main form would be in the format :

Expand|Select|Wrap|Line Numbers
  1. ([Project_ID] In(SELECT [Project_ID]
  2.                  FROM   [Project_River]
  3.                  WHERE  ([River_ID] = XXX)))
Where XXX is the value returned from your River ComboBox filter. Does that make it clearer? I see nothing here that relates to a cascading feature, but that may be because you simplified things. Also, this code assumes all your ID fields are numeric.

6 2558
NeoPa
32,556 Expert Mod 16PB
That sounds interesting, if somewhat more complicated than the details provided can support.

Can you give more details of exactly what connects to what and how. What depends on what. What triggers what. Such an understanding is critical to know how this should best be handled. Object names (Form names; Control names; Table names and Field names) also make it much easier to work within an explanation of your situation.

If you prefer, you can attach a copy of the database you're working on with your setup so far (See Attach Database (or other work) for details on how to do that).
Dec 9 '11 #2
Mihail
759 512MB
@Jewel8368
"I need to filter records in my form based on values in my subforms and I need them to cascade"

For me sound as a cycle.
Maybe I misunderstand. If not, that task can't be accomplished.
Dec 9 '11 #3
NeoPa
32,556 Expert Mod 16PB
Mihail:
For me sound as a cycle.
Indeed. A big reason why more details are needed. Maybe it's just a problem mis-expressed. It's not always easy to explain things clearly, even in one's own mother tongue.
Dec 9 '11 #4
Ok, my first priority is to filter my form based on combo box values. I can look at the cascading part after.

I have a table called projects and it has fields 'project_id', 'effective_date', 'issued_date', 'name', and 'type'. Each project could be related to multiple rivers and communities. I have a table for each: a river table that has fields 'river_id' and 'river' and a community table that has fields 'community_id' and 'community'. Then, to accommodate the two many to many relationships I have two more tables: a project_community table with fields 'project_id' and 'community_id' and a project_river table with 'project_id' and 'river_id'.

I have a form for adding projects and on this form I have 2 subforms. One that has a combo box for adding related rivers and another also with a combo box for adding related communities.

I need to add an unbound combo box in my form header that contains community values. When a value is selected, my form will filter to show only projects that are related to the selected value through the project_community table.
Dec 13 '11 #5
NeoPa
32,556 Expert Mod 16PB
So, each project can be related to multiple rivers, as well as multiple communities, and also multiple projects can be related to any of these same rivers or communities. Nice. In that case the filter string for the main form would be in the format :

Expand|Select|Wrap|Line Numbers
  1. ([Project_ID] In(SELECT [Project_ID]
  2.                  FROM   [Project_River]
  3.                  WHERE  ([River_ID] = XXX)))
Where XXX is the value returned from your River ComboBox filter. Does that make it clearer? I see nothing here that relates to a cascading feature, but that may be because you simplified things. Also, this code assumes all your ID fields are numeric.
Dec 13 '11 #6
I know it's been a long time but I'm ready to get back to this issue. I have 3 controls in the header to filter my form (Project Name keyword, type, and year). I have a button with the on click event code shown below to filter the form. I need to add a combo box for community and a combo box for flooding source to filter by. These two relations are as discussed previously. There can be a project with many communities and flooding sources. These values are stored in 2 subforms. I'm stuck on them being subforms and the relationships being in different tables.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Apply_Filter_Click()
  2. Dim strFilter As String
  3. strFilter = ""
  4.  
  5. If Me.fProjectName.Value = "" Or IsNull(Me.fProjectName) Then
  6. Else
  7. strFilter = "projectname Like '*" & Me.fProjectName & "*'"
  8. End If
  9.  
  10. If Me.fType.Value = "" Or IsNull(Me.fType) Then
  11. ElseIf strFilter = "" Then
  12. strFilter = strFilter & "type = '" & Me.fType & "'"
  13. Else
  14. strFilter = strFilter & "And type = '" & Me.fType & "'"
  15. End If
  16.  
  17. If Me.fYear.Value = "" Or IsNull(Me.fYear) Then
  18. ElseIf strFilter = "" Then
  19. strFilter = strFilter & "effectiveyear =" & Me.fYear & " OR issuedyear =" & Me.fYear
  20. Else
  21. strFilter = strFilter & "And (effectiveyear =" & Me.fYear & " OR issuedyear =" & Me.fYear & ")"
  22. End If
  23.  
  24. Me.Filter = strFilter
  25. Me.FilterOn = True
  26.  
  27. End Sub
Feb 28 '12 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: jfancy-Transport Canada | last post by:
Hi, I'm looking for an asp page to detect if there are any characters in my contact form that shouldn't be there. For example, if there is a "<" character, then this may mean there is html in my...
2
by: Andante.in.Blue | last post by:
Hello, I have just inherited a very undocumented legacy database, developed in and still running on Access 97. The file is an MDB file, with no security. It is placed in a shared directory on a...
2
by: Dalan | last post by:
Okay, I have worked on this and then some, but cannot seem to crack it. So if someone can straighten my code out, or suggest a new approach, then I'm all ears. Here goes: I have two tables - one...
1
by: George Papadopoulos | last post by:
Dear community I have recently created an MS-Access database to store and process the various phone numbers, phone devices we use in our hospital. I`m experiencing a problem creating a specific...
0
by: Mclaren | last post by:
Hi I have 3 tables: User, Customer and Customer order. I have a query that picks up all the orders captured for a given User. Each of the orders have a capture date. My main form is...
7
by: philelpko | last post by:
Good Morning all, I have a main form with 3 subforms. All of the input data on all the forms is stored in the same table. I started getting the message "the changes you requested to the table...
2
by: darnel | last post by:
I have 4 hierarchical tables and want to display it all together as a form and 3 subforms, when subform displays (and allow to add/edit) only relevant items from each superior subform. Tables are:...
0
by: Lyn | last post by:
I have a problem using the form .Filter and .FilterOn properties which causes Access to crash (as detailed in a separate post). The form operates in continuous mode, displaying matching records...
3
NeoPa
by: NeoPa | last post by:
Cascaded Form Filtering CHAPTER 1 - TABLE OF CONTENTS (Including attached database) CHAPTER 2 - INTRODUCTION CHAPTER 3 - TABLE LAYOUT CHAPTER 4 - FORM LAYOUT CHAPTER 5 - FORM MODULE CHAPTER 6...
6
by: garfieldsevilla | last post by:
I have two databases, one with products and another with accessories and a query which relates products and accessories. I created a simple report which lists the product fields and has two subforms....
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.