Clone macro in LibreOffice Base

68 Views Asked by At

I have a clone macro in a subform table control grid which copies 1 row to a clone table. It works perfectly if only 1 record. If another record is added, it still just copies the first. If there are many records and none have been copied and then the macro is run, it will copy the first record. If macro is run again, it will copy last record.If records are clicked on is no help. Does anyone know of additional code to be able to make any specific record the active record??

Sub Clone_To_New_Record (oEvent As Object) 'Button > Execute > event
        oForm = oEvent.Source.Model.Parent 'SubForm from Button 
        IF oForm.isNew THEN Exit Sub
    oForm.updateRow
        iID = oForm.Columns.GetByName("EX").Value
    oForm.moveToInsertRow
    oStatement = oForm.ActiveConnection.createStatement() 'Create an SQL statement object       
    sColumns = sColumns & """EX"""
    sColumns = sColumns & ", ""ID2"""
    sColumns = sColumns & ", ""DESCRIBE"""
        sColumns = sColumns & ", ""AMOUNT"""
        sSQL = "INSERT INTO ""CLONE2"" (" & sColumns & ") SELECT " & sColumns & " FROM ""EXPLAIN"" WHERE ""EX"" = " 
        & iID
    oStatement.executeUpdate( sSQL ) 'Execute the SQL command
    oForm.reload
    oForm.last
End Sub

I have looked at various posts that seem to be what I want, but either none worked or I put them in the wrong place. They all brought up various problems, but I don't know how to address them.

0

There are 0 best solutions below