Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I had a similar issue in LO Base. In Base 4.0 Handbook, some events are reported to run twice. I had this problem, when attached an event to a control using code. Not sure why, but following workaround succed.

First check if the control already has an assigned macro to the event you want to trigger from.

If not, assign the event.

If the event is already there, do nothing.

The following code might serve as an example. I'm using Access2Base. But you get the idea. I made a Close button, and assigned the macro from the module itself.

'+++ The following sub is attached to the Open Document Event. Tools -->Customize-->Events
Private Sub MyForm_OpenDocument()
        Call setControlEvents 
End Sub

Private Sub cmdClose
'+++Simple macro to close a form
    DoCmd.mClose(acForm, "myForm",0)
End Sub

Private Sub setControlEvents
    Dim ocCmdClose As Object
        Set ocCmdClose = Application.Forms("myForm").Controls("myCloseControl")

    If Len(ocCmdClose.OnActionPerformed) = 0 Then
           '+++If this event on the control has no macro attached, then do it.
    ocCmdClose.OnActionPerformed = "vnd.sun.star.script:Standard.MyModule.cmdClose?language=Basic&location=document"
    End If

    ocCmdClose = Nothing

End Sub

After doing this, the macro is called just once per event.