473,657 Members | 2,418 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

RowFilters with related tables

I have two tables, let's just say Master and Details. The Master is the
parent table, Details the child table.

What I want is to create a row filter on the children. But I also want to
create a row filter on the master table such that only master records that
have children that meet the criteria in the children table filter, will be
included.

That is, only master records with one or more qualifying children.

Can this be done with row filters? I mean, I could go through the child
table to get a list of all the unique foreign keys and do an IN operation on
them. I'd rather not go this way on several grounds including, we could be
talking about thousands of records and then you could end up with a really
huge filter string which would be undesirable. I guess what I'm looking for
is something more automatic that won't have to be modified if the child data
set is modified. I suspect there's not a way to do SQL style relational
filters, but thought it was worth asking just in case.

Pete

Nov 17 '05 #1
18 2809
Pete,

Reading your text I am in doubt if the select can help you.

http://msdn.microsoft.com/library/de...electtopic.asp

Otherwise I would go for the getchildrows and see if that is zero.
http://msdn.microsoft.com/library/de...drowstopic.asp

I hope this helps something

Cor
Nov 17 '05 #2
"Cor Ligthert [MVP]" <no************ @planet.nl> wrote in message
news:O1******** *****@TK2MSFTNG P10.phx.gbl...
Pete,

Reading your text I am in doubt if the select can help you.

http://msdn.microsoft.com/library/de...electtopic.asp

Otherwise I would go for the getchildrows and see if that is zero.
http://msdn.microsoft.com/library/de...drowstopic.asp

I hope this helps something

Cor


Thanks, but that's not going to do it. I guess what I neglected to mention
is this has to be done as a RowFilter since it's a DataViewManager which is
bound to a grid control. I want the grid to only show the parent rows for
parents that have children and the children which meet the row filter
criteria.

I know, this is probably some where in the land of obscurity. I mean, just
figuring out how to bind a grid to a DataViewManager and apply filters took
a bit of digging. MS didn't really go out of their way to document this
stuff.

Pete
Nov 17 '05 #3
If your tables/database is properly normalized (4th normal form) then
iterate through the associate table.. MasterDetail which you would have
built to resolve the many to many relationships between the tables.

Cheers

Denis
"Pete Davis" <pdavis68@[nospam]hotmail.com> wrote in message
news:o7******** ************@gi ganews.com...
I have two tables, let's just say Master and Details. The Master is the
parent table, Details the child table.

What I want is to create a row filter on the children. But I also want to
create a row filter on the master table such that only master records that
have children that meet the criteria in the children table filter, will be
included.

That is, only master records with one or more qualifying children.

Can this be done with row filters? I mean, I could go through the child
table to get a list of all the unique foreign keys and do an IN operation on them. I'd rather not go this way on several grounds including, we could be
talking about thousands of records and then you could end up with a really
huge filter string which would be undesirable. I guess what I'm looking for is something more automatic that won't have to be modified if the child data set is modified. I suspect there's not a way to do SQL style relational
filters, but thought it was worth asking just in case.

Pete

Nov 17 '05 #4

"Denis Dougall" <De***********@ moh.gov.on.ca> wrote in message
news:Oh******** ******@TK2MSFTN GP14.phx.gbl...
If your tables/database is properly normalized (4th normal form) then
iterate through the associate table.. MasterDetail which you would have
built to resolve the many to many relationships between the tables.

Cheers

Denis


It's not many to many. It's one to many and there is no associate table.

I think you're misunderstandin g the question. The question is more in
regards to how to implement my requirements via a RowFilter.

Pete
Nov 17 '05 #5
Hi,

When filling the Master data, set your SQL to pull the data only if
they have the related child rows
i.e Select m.a,m.b,m.c from master m where m.a in (select distinct
child.a from child)

It might be in-efficient. But can definitely be looked at & query can
be optimized

Does it help ?

Kalpesh

Nov 17 '05 #6
> Hi,

When filling the Master data, set your SQL to pull the data only if
they have the related child rows
i.e Select m.a,m.b,m.c from master m where m.a in (select distinct
child.a from child)

It might be in-efficient. But can definitely be looked at & query can
be optimized

Does it help ?


Again, I need this to be done via RowFilters, not via the SQL. Basically,
here's how it works:

I have a DataViewManager bound to a grid control. The grid is hierarchical
and shows Master and Detail records. Above that, I have a Filter control
that lets the user select columns and values. When they set a value, I then
apply a RowFilter along the lines of:

dvm.DataViewSet tings[detailsDataTabl e].RowFilter = "Department ID = 4"

This will filter all detail records showing only those for DepartmentID = 4.
Now, I only want the Master records that have children that have
DepartmentID=4.

I don't want to have to reget the data from the data source as this wouldn't
be feasible from a performance standpoint.

Pete
Nov 17 '05 #7
Can you clone a table and populate the clone with the "matching" entries?
similiar to http://www.codeproject.com/csharp/Pr...DataGrids4.asp
5.5 Cloning?
"Pete Davis" <pdavis68@[nospam]hotmail.com> wrote in message
news:Is******** ************@gi ganews.com...

"Denis Dougall" <De***********@ moh.gov.on.ca> wrote in message
news:Oh******** ******@TK2MSFTN GP14.phx.gbl...
If your tables/database is properly normalized (4th normal form) then
iterate through the associate table.. MasterDetail which you would have
built to resolve the many to many relationships between the tables.

Cheers

Denis


It's not many to many. It's one to many and there is no associate table.

I think you're misunderstandin g the question. The question is more in
regards to how to implement my requirements via a RowFilter.

Pete

Nov 17 '05 #8
> Can you clone a table and populate the clone with the "matching" entries?
similiar to http://www.codeproject.com/csharp/Pr...DataGrids4.asp
5.5 Cloning?


No, this isn't feasible. I don't want to rebind the grid to a new datatable.
I don't want to create a new dataset. I need this to be done via the
RowFilter in the DataViewManager , if possible. If it's not possible then I
have plenty of other ways I can do it that are really not desirable. My
question is, can it be done with a RowFilter and if so, how?

Pete
Nov 17 '05 #9
Pete,

In my opinion can you not create this using a filter in SQL and as well will
you not be able to do that in a dataset. Because there is nothing to filter,
it is matching.

The same as in SQL you can use the getchildrows to make a seperate table.

I hope this helps,

Cor

"Pete Davis" <pdavis68@[nospam]hotmail.com> schreef in bericht
news:4N******** ************@gi ganews.com...
"Cor Ligthert [MVP]" <no************ @planet.nl> wrote in message
news:O1******** *****@TK2MSFTNG P10.phx.gbl...
Pete,

Reading your text I am in doubt if the select can help you.

http://msdn.microsoft.com/library/de...electtopic.asp

Otherwise I would go for the getchildrows and see if that is zero.
http://msdn.microsoft.com/library/de...drowstopic.asp

I hope this helps something

Cor


Thanks, but that's not going to do it. I guess what I neglected to mention
is this has to be done as a RowFilter since it's a DataViewManager which
is bound to a grid control. I want the grid to only show the parent rows
for parents that have children and the children which meet the row filter
criteria.

I know, this is probably some where in the land of obscurity. I mean, just
figuring out how to bind a grid to a DataViewManager and apply filters
took a bit of digging. MS didn't really go out of their way to document
this stuff.

Pete

Nov 17 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
11096
by: Jason | last post by:
I am trying to filter records in a primary form based on records in related tables. The data in the related tables is being displayed in the primary form through subforms. To be more specific, I have a primary form named TestResults, which is connected to data in a table named TestResults. There are basically two other tables that are related to the TestResults table (and the primary form) named Names-Normalized and SiteAddresses. The...
1
1679
by: Christa Waggett | last post by:
Hi, I'm not a programmer but would appreciate some help with the following. I've been looking at various sites but cannot find the information I require. I have a table of strata plans and if we no longer manage the plan the date this occurs gets entered into a field. What I would like to happen is for all the fields in that record to change their forecolor to red as soon as the DateLost field is no longer null. I also have several...
2
990
by: Masa Ito | last post by:
The rowfilter in a dataview seems to support a very limited subset of regex expressions. I need to filter a column of strings by their length. ie: if 2 character code, or 3 character code. Currently, I am looping all the rows, and deleting them when they don't match the length. Resetting/loading the datasource every time a new filter is applied. This is slow - I need a better way.
4
3298
by: HLCruz via AccessMonster.com | last post by:
I am working with a database that has client information separated in to 4 related tables - tFolder, tAddress, tEmail, tPhone number. In addition there are related tables tGifts and tCalls. The database has roughly 22,000 records but should only have around 6,000. The remaining records are duplicates, but in many cases the correct data for one person is spread out between the duplicate records and related tables. I need to be able to...
2
2745
by: Mark Rae | last post by:
Hi, This isn't *specifically* an ASP.NET question, so I've also posted it in the ADO.NET group - however, it's not too far off-topic... Imagine a SQL Server 2005 database with a table with an int column used for bitwise data - you know the sort of thing... 0, 1, 2, 4, 8, 16 etc intBitwise strName ----------------------
4
2100
by: db2admin | last post by:
Hello, I want to plan rearranging tables in our database according to business areas. say all tables in business area A will be in seperate tablespace or tablespaces. I am planning to monitor activity on tables for a month by taking snapshots on tables and then i will see if this rearrangement is possible. What are the factors, measures etc. i should consider for rearranging tables.
11
3665
by: shriil | last post by:
Hi I have this database that calculates and stores the incentive amount earned by employees of a particular department. Each record is entered by entering the Date, Shift (morn, eve, or night) and the 'employee name'. There is another table which assigns an ID to the Shifts, i.e. 1,2 and 3 for morn, eve & night shifts respectively. From the mother table, the incentive is calculated datewise for each employee as per his shift duty. In...
5
4146
by: upwardgazing | last post by:
I'm using Access 2003 (Access 2000 file format) and I have two tables related one-to-many called tblTempEncounter and tblTempEncounterDetails. I need to move a record from the first table with it's related records from the second table into another pair of tables called tblEncounters and tblEncounterDetails. I've come up with a solution that seems really convulted to me, and it's snagging with multiple users. Will a single append query move data...
3
1898
by: BASSPU03 | last post by:
(I'm using Access 2003 on a Windows XP O/S.) I have four tables that are related in the following order: tblFiscalYear > tblBulkObligations > tblProjects > tblResources These are their fields: tblFiscalYear ==========
0
8402
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8829
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8734
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8508
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8608
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6172
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5633
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
1962
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1627
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.