Alpha DevCon 2018
Results 1 to 5 of 5

Thread: Duplicate record on focus

  1. #1
    Member
    Real Name
    K Aponkye
    Join Date
    Oct 2006
    Posts
    279

    Default Duplicate record on focus

    Could someone please give me a script to duplicate a record on focus after entering the data on the last field. I have a duplicate button script that has this script that I got from the help section. Below is the script attached to the button.

    topparent.duplicate_record(1)

    but anytime I click on the button I get this message that says "you must be in view mode to duplicate the current record".

    I am using this button to speed up dataentry. I am using A5v7.
    It works when I click on the next page arrow and come back to press the button. My belief is that I get the message because at the time I press the button the data is not committed to the database. How do I do the commit and at the same time get the duplicate record when the button is pressed.


    Thanks

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

    Default Re: Duplicate record on focus

    Code:
    topparent.commit()
    topparent.duplicate_record(1)

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

    Default Re: Duplicate record on focus

    I have had problems with the duplicate_record() function. I believe it was Cal Locklin that recommended this method, which has always worked well for me, since.

    Code:
    tbl = table.current()
    
    record_data = tbl.record_data_get()
    target = table.open("Yourcurrenttable")
    target.enter_begin()
    target.record_data_set(record_data)
    target.enter_end(.T.)
    
    ' this section if you want to amend certain elements of the duplicated record
    target.change_begin()
    	target.field1 = value1
    	target.field2 = value2
    target.change_end(.t.)
    ' end of amend segment
    
    target.close()
    
    topparent.resych()
    topparent.refresh_layout()
    Mike W
    __________________________
    "I rebel in at least small things to express to the world that I have not completely surrendered"

  4. #4
    Member
    Real Name
    K Aponkye
    Join Date
    Oct 2006
    Posts
    279

    Default Re: Duplicate record on focus

    Thanks to you both.

    K

  5. #5
    Member
    Real Name
    Allison Chavez
    Join Date
    Oct 2014
    Posts
    1

    Default Re: Duplicate record on focus

    I am having this same issue but I cannot get anything to work

Similar Threads

  1. Record Focus Problem
    By pps in forum Alpha Five Version 5
    Replies: 4
    Last Post: 12-23-2005, 04:52 PM
  2. record focus
    By Cheryl Lemire in forum Alpha Five Version 5
    Replies: 16
    Last Post: 07-20-2004, 08:28 AM
  3. Record Focus
    By julian lewis in forum Alpha Five Version 5
    Replies: 8
    Last Post: 07-03-2004, 01:48 PM
  4. Highlighted focus on record
    By NBGH in forum Alpha Five Version 5
    Replies: 0
    Last Post: 03-09-2003, 11:36 AM
  5. Record Loses Focus
    By Thomas Holt in forum Alpha Five Version 4
    Replies: 4
    Last Post: 11-12-2002, 05:53 AM

Posting Permissions

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