Macros in Subform

I have this macro which clones a record in the subform grid.
It does clone a record to table, but the first click on button
clones the very first record in the table, then another click clones the
current record in the grid. Can anyone see something that could cause this.
Debian9 LO 5.2.2.2
Thank You, Pumper

CloneMacSub.odt

Hello,

Not having your complete setup, I created a form (no sub form) and with your exact code had no problem as you state. First click on button copied the record pointed at.

I used Ubuntu 20.04 with LO v7.1.1.2 and an HSQLDB embedded database.

Thanks for your time in that, but I also use similar macro in main form and it works.
Could you please try it in a sub form grid

There are too many ways to have a sub form grid. Please first describe (or provide a sample) your main form & sub form grid.

Edit:

OK, have now tried with a sub form. As I suspected there was no problem. The selected record was the one cloned. It never cloned the first record unless I select it.

At this point I cannot keep guessing where your problem lies. Need a sample of Base file where this occurs. Please no personal/confidential information.