Alpha Video Training
Results 1 to 2 of 2

Thread: Update child recs bases on parent filter

  1. #1
    "Certified" Alphaholic
    Real Name
    Michael Humby
    Join Date
    Apr 2000
    Location
    Leicester, UK
    Posts
    1,036

    Default Update child recs bases on parent filter


    If like me you often need to update/change selected child records based upon a value in the parent record, and you find this tricky.
    e.g. Change a value in all child records for the month of May but only if the parent value in FieldX is = to 'Yes'.

    Attached is an example script that will do this.

    I would be grateful of any comments or suggested improvements.

  2. #2
    "Certified" Alphaholic
    Real Name
    Michael Humby
    Join Date
    Apr 2000
    Location
    Leicester, UK
    Posts
    1,036

    Default RE: Update child recs bases on parent filter

    This script was written by Steve Dentler giving the same result and is an impovement on mine.

    t=table.current(1)
    c=table.current(2)
    query.description="With Leave dates"
    query.order = ""
    query.filter = "RTRIM(Pay_termly)='Yes'"
    query.option="M"
    idx = t.query_create()
    t.fetch_first(1)

    while .not. t.fetch_eof()
    c.fetch_first()
    while .not. c.fetch_eof()
    if c.f_month=Month_var
    c.change_begin()
    c.term_note="testdata"
    c.change_end(.t.)
    end if
    c.fetch_next()
    end while
    t.fetch_next(1)
    end while

    idx.drop()
    ui_msg_box("Done","")
    end


    Michael

Similar Threads

  1. Number of child recs belonging to parent
    By Jim Chapman in forum Archived Wishlist
    Replies: 5
    Last Post: 07-26-2005, 07:11 AM
  2. Update of Set Child with Parent fields
    By lgoode in forum Alpha Five Version 6
    Replies: 4
    Last Post: 06-23-2005, 02:29 PM
  3. Update - uses all recs not selected
    By dik_coleman in forum Alpha Five Version 6
    Replies: 2
    Last Post: 03-13-2005, 08:40 AM
  4. Update To Parent From Child
    By Thomas Holt in forum Alpha Five Version 4
    Replies: 3
    Last Post: 06-26-2003, 08:11 AM
  5. Filter Parent With Child
    By Jamin Dunivan in forum Alpha Five Version 4
    Replies: 1
    Last Post: 05-31-2000, 02:45 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
  •