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?
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 : - ([Project_ID] In(SELECT [Project_ID]
-
FROM [Project_River]
-
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).
@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.
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.
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.
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 : - ([Project_ID] In(SELECT [Project_ID]
-
FROM [Project_River]
-
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.
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. - Private Sub Apply_Filter_Click()
-
Dim strFilter As String
-
strFilter = ""
-
-
If Me.fProjectName.Value = "" Or IsNull(Me.fProjectName) Then
-
Else
-
strFilter = "projectname Like '*" & Me.fProjectName & "*'"
-
End If
-
-
If Me.fType.Value = "" Or IsNull(Me.fType) Then
-
ElseIf strFilter = "" Then
-
strFilter = strFilter & "type = '" & Me.fType & "'"
-
Else
-
strFilter = strFilter & "And type = '" & Me.fType & "'"
-
End If
-
-
If Me.fYear.Value = "" Or IsNull(Me.fYear) Then
-
ElseIf strFilter = "" Then
-
strFilter = strFilter & "effectiveyear =" & Me.fYear & " OR issuedyear =" & Me.fYear
-
Else
-
strFilter = strFilter & "And (effectiveyear =" & Me.fYear & " OR issuedyear =" & Me.fYear & ")"
-
End If
-
-
Me.Filter = strFilter
-
Me.FilterOn = True
-
-
End Sub
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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:...
|
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...
|
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...
|
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....
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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,...
|
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...
|
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...
|
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...
|
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: 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...
|
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...
| |