duplication of child record

I’ve got an invoice table, with an invoice lines child table related to it. When the user duplicates an invoice, how do I get the invoice lines to duplicate along with the parent record?

Have a look here, it works like a treat.
http://forum.servoy.com/viewtopic.php?t=7422&highlight=