I am not certain exactly where you have gone wrong, but here is the code that I use myself.
The following code sets up a function that can be used to open any form.
Code: Select all
Sub OpenForm( oEvent as variant, aFormName as string) as variant
Dim args(1) As New com.sun.star.beans.PropertyValue
Dim container as variant
container = oEvent.Source.Model.Parent.ActiveConnection.Parent.DatabaseDocument.FormDocuments
args(0).Name = "ActiveConnection"
args(0).Value = oEvent.Source.Model.Parent.ActiveConnection
args(1).Name = "OpenMode"
args(1).Value = "open"
container.loadComponentFromURL(aFormName,"_blank",0,args())
End Sub
Next you need to add a function that will call this first function and pass it the name of the form you want to open.
Code: Select all
Sub onClickOpenForm ( oEvent as variant )
OpenForm(oEvent, "My Form Name")
End sub
Using this method you can set up additional functions for all of your forms. For example if you have a form called "Index Form", you could have the method:
Code: Select all
Sub onClickOpenIndexForm ( oEvent as variant )
OpenForm(oEvent, "Index Form")
End sub
The final step is then to assign the new "onClickOpen..." function to the appropriate button on your form, although I tend to use the "When Initiating" event for the button rather than the "Mouse button released" event