Alpha Video Training
Results 1 to 6 of 6

Thread: Copy current selected ?

  1. #1
    Member
    Real Name
    Marc King
    Join Date
    Dec 2002
    Location
    California
    Posts
    702

    Default Copy current selected ?

    Hey everyone,

    I have a simple set - Header 1-"M child

    The header has four records. Each child relation has ten records.

    I have a form with a header browse and a child browse. So I can select the header record and see the corresponding ten child records.

    I have a copy records script that is set to copy the child table "currently selected records" to a dummy table.

    When I select a header - showing the desired child records in the browse and run the copy records script I get all 40 records from the child table in the dummy table. Not just the ten showing in the browse.

    How do I need to set this up so I can select a header record and copy the only the related child records to the dummy table?

    Thanks
    Marc

  2. #2
    "Certified" Alphaholic Scott Emerick's Avatar
    Real Name
    Scott Emerick
    Join Date
    Dec 2000
    Location
    Central Virginia/ North Carolina Border
    Posts
    2,154

    Default RE: Copy current selected ?

    Marc,

    Try something like this, Change the linkingfield to the actual field in the table as well as your table names:

    dim mm as p
    dim mc as p
    dim kount as n

    mc = table.current(2)
    mc2=table.open(DUMMYTABLE)

    kount = count(mychild->LINKINGFIELD,GRP->HEADER)

    ''Copy the child records to new table
    IF kount>0 THEN
    mc.fetch_first()
    WHILE .not. mc.fetch_eof()
    mc_rec=mc.record_data_get()
    mc2.enter_begin()
    mc2.record_data_set(mc_rec)
    mc2.enter_end(.t.)
    mc.fetch_next(1)
    END WHILE
    END IF

    'Close Opened table
    mc2.close()

    Hope this helps,

    Scott

  3. #3
    Member
    Real Name
    Marc King
    Join Date
    Dec 2002
    Location
    California
    Posts
    702

    Default RE: Copy current selected ?

    Thanks Scott, I'll check it out

    Marc

  4. #4
    "Certified" Alphaholic
    Real Name
    JohnZaleski
    Join Date
    Oct 2000
    Posts
    1,736

    Default RE: Copy current selected ?

    If you are on a form based on the set, this variation of Scott's code will dupe the records just for the current parent.Counting isn't necessary.

    mc = table.get("childtablename")
    mc2=table.open(DUMMYTABLE)

    mc.fetch_first()
    WHILE .not. mc.fetch_eof()
    mc_rec=mc.record_data_get()
    mc2.enter_begin()
    mc2.record_data_set(mc_rec)
    mc2.enter_end(.t.)
    mc.fetch_next(1)
    END WHILE

  5. #5
    "Certified" Alphaholic Scott Emerick's Avatar
    Real Name
    Scott Emerick
    Join Date
    Dec 2000
    Location
    Central Virginia/ North Carolina Border
    Posts
    2,154

    Default RE: Copy current selected ?

    ooops ... your right John. I clipped this from a much larger code that copied several child and grandchild tables.

  6. #6
    Member
    Real Name
    Marc King
    Join Date
    Dec 2002
    Location
    California
    Posts
    702

    Default RE: Copy current selected ?

    Works like a charm!

    Thanks
    Marc

Similar Threads

  1. copy selected text
    By ken in forum Alpha Five Version 6
    Replies: 0
    Last Post: 08-18-2005, 11:02 AM
  2. Copy record to current record not working
    By Larry Ternowski in forum Alpha Five Version 6
    Replies: 3
    Last Post: 07-15-2005, 05:01 AM
  3. Get selected text.
    By Blake in forum Alpha Five Version 5
    Replies: 9
    Last Post: 08-13-2004, 10:42 AM
  4. How to Copy values of current record
    By John Panagia in forum Alpha Five Version 5
    Replies: 15
    Last Post: 05-19-2003, 05:29 PM
  5. No printer selected
    By Edward F. Schulz in forum Alpha Five Version 4
    Replies: 8
    Last Post: 01-24-2002, 06:12 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
  •