Board index » delphi » Filtering/Or whatever other way works

Filtering/Or whatever other way works

I have a form with fields from a master table on it and a dbgrid with the
child table linked to it.  What I want to do is allow the user to filter on
fields from the master table or the child table.  Let's say the master and
child tables are linked on ID.  The child table contains addresses.  Now
here's the question.  If the user only wants to filter on a field from the
child table, let's say state, how can I limit the records from the master
table to only those that have the state that was selected?  Currently, I
still get all of the master records, and only the filtered child records.

Thanks
Jim

 

Re:Filtering/Or whatever other way works


The easiest way is to use a query.  The other althernative is to use another
form with the link to the tables reversed.  Make the child in the first form
the master in the second.  Then you can filter the talbe and see the master
record linked to the child as you scroll from child to child.

--
Bill

(TeamB cannot answer questions received via email.)
(To contact me for any other reason remove nospam from my address)

Re:Filtering/Or whatever other way works


On Wed, 3 Jun 1998 11:06:58 -0700, "Jim Ley" <james...@hotmail.com>
wrote:

Quote
>I have a form with fields from a master table on it and a dbgrid with the
>child table linked to it.  What I want to do is allow the user to filter on
>fields from the master table or the child table.  Let's say the master and
>child tables are linked on ID.  The child table contains addresses.  Now
>here's the question.  If the user only wants to filter on a field from the
>child table, let's say state, how can I limit the records from the master
>table to only those that have the state that was selected?  Currently, I
>still get all of the master records, and only the filtered child records.

>Thanks
>Jim

I am assuming you have a one-to-one relationship or at least one where
each master record corresponds to child records that can have only one
state. In that case, you can replicate the state field into the master
record or, for that matter, delete it from the child record since of
the above assumption. In that case, you can just set a range or filter
on the master table as appropriate. If you have the possibility of
having child records with different states, then you can't do what you
want anyway.

Steve F (Team B)

Other Threads