Alpha DevCon 2018
Results 1 to 18 of 18

Thread: Can a 1:M set be filtered for one Parent and selected childs?

  1. #1
    "Certified" Alphaholic Mike Wilson's Avatar
    Real Name
    mike wilson
    Join Date
    Apr 2005
    Location
    Michigan
    Posts
    4,133

    Default Can a 1:M set be filtered for one Parent and selected childs?

    Attached is an example of a set with parent 1:M child. Can the parent table be filtered to one parent and also have the linked children be filtered to a select group of child records? if so...how? (The names are in separate fields. Below is just a visual of what I desire.) The parent is viewed through an embedded browse. I only wantto see the one parent.

    Code:
    Parent	                 Child
    Lincoln, Abe	            Lincoln, Kim
    	                    Lincoln, Karl
    	                    Lincoln, Bob
    washington, george          washington, Jim
    	                    washington, John
    	                    washington, Jill
    	                   washington, Karen
    	                   washington, Bill
    Mike W
    __________________________
    "I rebel in at least small things to express to the world that I have not completely surrendered"

  2. #2
    "Certified" Alphaholic G Gabriel's Avatar
    Real Name
    G. Gabriel
    Join Date
    Oct 2004
    Posts
    7,193

    Default Re: Can a 1:M set be filtered for one Parent and selected childs?

    Didn't we do this once before... long time ago..in a galaxy far far away?

    Run the topparent.queryrun() twice:
    First filtering the parent at cross level
    Then filtering at the child level.

  3. #3
    "Certified" Alphaholic
    Real Name
    Tom Cone Jr
    Join Date
    Apr 2000
    Location
    Florida
    Posts
    23,300

    Default Re: Can a 1:M set be filtered for one Parent and selected childs?

    Mike,

    Here's an example that achieves the desired result by manipulating the filter expressions applicable to the tables supporting the form. This approach can break the set linkages so it should be used with care. See, Toms_Form for the example buttons.

    G, another lap around the track might be useful to some. How about putting an example together using the supplied database?

    -- tom

  4. #4
    "Certified" Alphaholic Mike Wilson's Avatar
    Real Name
    mike wilson
    Join Date
    Apr 2005
    Location
    Michigan
    Posts
    4,133

    Default Re: Can a 1:M set be filtered for one Parent and selected childs?

    Gabe,
    Thanks, that method to establish the query worked well. Although, I have yet to figure out how to undo/drop/break the query combination.

    Tom,
    Thank you very, very much. Establishing the filter AND reversing the query work well!
    Mike W
    __________________________
    "I rebel in at least small things to express to the world that I have not completely surrendered"

  5. #5
    "Certified" Alphaholic Tim Kiebert's Avatar
    Real Name
    Tim Kiebert
    Join Date
    Jul 2004
    Location
    Geelong, Victoria, Australia
    Posts
    2,784

    Default Re: Can a 1:M set be filtered for one Parent and selected childs?

    Mike,

    I took a similar approach to Tom. But I split the difference. Set the base query of the form at the parent level to 'Washington' and then queryrun() on the child for 'J'. This way you can use the show all button leaving the parent filter but clearing the child filter and allowing you to filter on a different letter.

    EDIT: My code is on the bottom two buttons.
    Tim Kiebert
    Geelong Citrus Packers
    A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

  6. #6
    "Certified" Alphaholic Mike Wilson's Avatar
    Real Name
    mike wilson
    Join Date
    Apr 2005
    Location
    Michigan
    Posts
    4,133

    Default Re: Can a 1:M set be filtered for one Parent and selected childs?

    Tim,
    I couldn't quite find a way to break through the filter on the child table after using queryrun() without resorting to using the explicite filters and queries. 'Show All' did nothing as far as I could see, for the child tables. BUT I got it working the way I needed and I think is a good example of filtering parent and child tables (see attached).

    Tom, Tim, as always, you have helped me greatly!

    A few words for searchers (me mostly):
    Keywords: filter parent child set, filtering child table, filter child table in parent-child set, filter child browse, independantly.
    Last edited by Mike Wilson; 10-19-2007 at 01:58 PM.
    Mike W
    __________________________
    "I rebel in at least small things to express to the world that I have not completely surrendered"

  7. #7
    "Certified" Alphaholic Tim Kiebert's Avatar
    Real Name
    Tim Kiebert
    Join Date
    Jul 2004
    Location
    Geelong, Victoria, Australia
    Posts
    2,784

    Default Re: Can a 1:M set be filtered for one Parent and selected childs?

    Mike,

    In my example (pcfilter2) to release the child query using the form's show all button you have to activate the child browse first by clicking in it and then F5 to refresh the form. Using code (which I didn't include) would be
    Code:
    topparent:Browse1.show_all()
    topparent:Browse1.fetch_first()
    I have attached an other sample for you again using a queryrun for the child. There is also a second form using queryrun() for the parent as well as per Gabe' suggestion (almost). For the parent query the queryrun was set to the parent table instead of <crosslevel>.
    Tim Kiebert
    Geelong Citrus Packers
    A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

  8. #8
    "Certified" Alphaholic Mike Wilson's Avatar
    Real Name
    mike wilson
    Join Date
    Apr 2005
    Location
    Michigan
    Posts
    4,133

    Default Re: Can a 1:M set be filtered for one Parent and selected childs?

    Tim,
    Outstanding! I have to share with ya'll (I have roots in Texas,.. Hi Martin), that this thread has consolidated a huge, lingering vacancy for me.. and I hope others can appreciate the thread also.

    Thank you all, big time!! (another Texan term).
    Mike W
    __________________________
    "I rebel in at least small things to express to the world that I have not completely surrendered"

  9. #9
    "Certified" Alphaholic G Gabriel's Avatar
    Real Name
    G. Gabriel
    Join Date
    Oct 2004
    Posts
    7,193

    Default Re: Can a 1:M set be filtered for one Parent and selected childs?

    Tom:
    This approach can break the set linkages so it should be used with care.
    Just got around to opening zip files. Like your approach as a pretty good alternative and don't see any concern that it might break the link.

    Perhaps, only advantages of querryrun() over that would be:
    a-Not sure if your approach will open a second instance of the table or not. Maybe not.
    b-ability to sort. Maybe you could add a sorting element to your approach.
    Resolving these two issues would make these two approaches equally good.

    Tim:
    Didn't open your zip and assumed your approach is a hybrid between querryrun() and Tom's.

    Mike:
    To show all:
    Re-run queryrun() and use as a filter .t.

    Hopefully, this will put this baby to sleep.

  10. #10
    "Certified" Alphaholic Mike Wilson's Avatar
    Real Name
    mike wilson
    Join Date
    Apr 2005
    Location
    Michigan
    Posts
    4,133

    Default Re: Can a 1:M set be filtered for one Parent and selected childs?

    Quote Originally Posted by G Gabriel View Post
    Hopefully, this will put this baby to sleep.
    Curly:
    snooooorrrrr,...... woop oop, oop, oop, oop, oop

    snooooorrrrr...............wopp, oop, oop, oop, oop, oop

    snooooorrrrr,............wopp, oop, oop, oop, oop, oop
    Mike W
    __________________________
    "I rebel in at least small things to express to the world that I have not completely surrendered"

  11. #11
    "Certified" Alphaholic Mike Wilson's Avatar
    Real Name
    mike wilson
    Join Date
    Apr 2005
    Location
    Michigan
    Posts
    4,133

    Default Re: Can a 1:M set be filtered for one Parent and selected childs?

    I'm going to bump this thread because the original question was actually not solved. The need I have again is to filter the Parent table for values found in the child table. I found this thread searching for "filter parent". In the example below, what expression gets the parent table filtered to show Alabama and Maine for the query for states with towns named Milton. I used to be able to use inlist2() but now my expression length exceeds the 1024 character expression limit.

    Code:
    PARENT     CHILD
    States       Towns
    
    Alabama      Milton
    	     Frankton
    	     West Niles
    	     Grettle
    
    Michigan     Rapidsville
                 Westmont
                 Hillsdale
                 Hilltop
    
    Maine	     Milton
    	     Clarksville
    	     Trenton
    	     Victory
    Mike W
    __________________________
    "I rebel in at least small things to express to the world that I have not completely surrendered"

  12. #12
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Can a 1:M set be filtered for one Parent and selected childs?

    Where do you need to see/do this. It is exceedingly simple with an inverse of the current set.
    There can be only one.

  13. #13
    "Certified" Alphaholic
    Real Name
    Tom Cone Jr
    Join Date
    Apr 2000
    Location
    Florida
    Posts
    23,300

    Default Re: Can a 1:M set be filtered for one Parent and selected childs?

    Mike, you've changed to a different (but admittedly similar) question. <grin>

  14. #14
    "Certified" Alphaholic G Gabriel's Avatar
    Real Name
    G. Gabriel
    Join Date
    Oct 2004
    Posts
    7,193

    Default Re: Can a 1:M set be filtered for one Parent and selected childs?

    Mike:
    Have you looked into flattenquerry()?

  15. #15
    "Certified" Alphaholic Mike Wilson's Avatar
    Real Name
    mike wilson
    Join Date
    Apr 2005
    Location
    Michigan
    Posts
    4,133

    Default Re: Can a 1:M set be filtered for one Parent and selected childs?

    The outcome is seeing the filtered parent records and child records in a set based on parent (1:M) child set. So the inverted set isn't an option here. I have never had success with flattenquerry()..... EXCEPT FOR TONIGHT!!!! That is the ticket!! Thanks for the bump Gabe!

    The set: Ship_docs_hdr (parent) Ship_docs_events (child)

    Code:
    dim vship_vendor_id as C="VND.00039"
    DIM records_found as N
    records_found = topparent.queryrun(flattenquery("ship_docs_events->Ship_Vend_Id="+quote(vship_vendor_ID)),"","","No","<Cross Level>",.f.)
    Mike W
    __________________________
    "I rebel in at least small things to express to the world that I have not completely surrendered"

  16. #16
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Can a 1:M set be filtered for one Parent and selected childs?

    Don't understand why an inverted set wouldn't show you what you want to see. Events to header one to one simply filtered on the vend_id would display only linked parent records.
    There can be only one.

  17. #17
    "Certified" Alphaholic Mike Wilson's Avatar
    Real Name
    mike wilson
    Join Date
    Apr 2005
    Location
    Michigan
    Posts
    4,133

    Default Re: Can a 1:M set be filtered for one Parent and selected childs?

    Hi Stan,
    It's not that it wouldn't work, I'm sure it would. It's that the form that the user is working in is based upon the Parent-Child set. I believing that for viewing and working the results that you describe would require viewing another form based on the inverted set. I think I have that correct.
    Mike W
    __________________________
    "I rebel in at least small things to express to the world that I have not completely surrendered"

  18. #18
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Can a 1:M set be filtered for one Parent and selected childs?

    Inverted set would have the same tables, and thus the same fields. Should be able to copy the current form to the new set with only minor changes if any and switch from one to the other. Whatever works for you.
    There can be only one.

Similar Threads

  1. set color of selected multistate button
    By Steve Wood in forum Alpha Five Version 8
    Replies: 4
    Last Post: 02-25-2007, 07:29 AM
  2. Set Session Variable Based on Selected Grid Row
    By rsmereka in forum Web Application Server v7
    Replies: 10
    Last Post: 01-08-2007, 12:22 PM
  3. Form w Filtered Browse using Set
    By MoGrace in forum Alpha Five Version 6
    Replies: 0
    Last Post: 05-31-2006, 06:53 PM
  4. showing only a selected record in set based form
    By MikeC in forum Alpha Five Version 5
    Replies: 4
    Last Post: 03-27-2006, 12:06 AM
  5. How to duplicate selected records in a Set?
    By Tim Fitz-Randolph in forum Alpha Five Version 4
    Replies: 2
    Last Post: 06-05-2000, 08:50 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •