I need to write a script to copy a found set of records and change the report number for the copied records.
PERFORM FIND (original inspection record)
GOTO RELEATED RECORD (generates a foundset of the photographs related to the above inspection - the cursor lands on the first record)
DUPLICATE RECORD/REQUEST (duplicates the first record and creates it just below the record that it copied)
SET FIELD Report Number = 666 (giving the new picture records the report number of the new inspection)
GO TO NEXT RECORD REQUEST/NEXT EXIT IF LAST (go to the next record in the foundset)
My earlier version worked fine: The GOTO RELATED RECORD found the matching records and landed on the first record of the found set. The DUPLICATE copied the first record just below the one it copied and then set it to the new report number, went to the next record (number 2 of the original foundset) and did the same thing over and over which was great each time duplicating the record just before it and placing the new record just below the one it copied.
The new version (running the same code) the GOTO RELATED RECORD found the matching records and landed on the first record of the found set (so far so good) but when the DUPLICATE RECORD executed, it created the duplicate AT THE END OF THE FOUNDSET. The GOTO NEXT detected that it was at the end of the foundset and exited the script.
How do I get the DUPLICATE command to create the new record just below the record copied or do I take a whole new approach???