Macro To Open A Link From Sub-Form

I typically use an Action Button on a Form with the following macro, to open a webpage:

Sub OpenLink
oForm = ThisComponent.Drawpage.Forms.getByName(“frmMovies”)
DocCtl = ThisComponent.getCurrentController()
oField = oForm.getByName(“txtIMDB”)
oButton = oForm.getByName(“OpenIMDB”)
CtlView = DocCtl.GetControl(oField)
oButton.TargetUrl = CtlView.Text
End sub

So far, so good, but now I have “oField” and “oButton” in a SubForm and I still don’t know how to use “oSubForm” in this macro. Could someone help me?
Thank you in advance.
I use LibreOffice Base 25.8.4

Sub OpenLink(oEvent AS OBJECT)
oButton = oEvent.Source.Model
oForm = oButton.Parent
DocCtl = ThisComponent.getCurrentController()
oField = oForm.getByName(“txtIMDB”)
CtlView = DocCtl.GetControl(oField)
oButton.TargetUrl = CtlView.Text
End sub

So you could use the button in every form. Button only need to be a part of the form.

1 Like

Dear Mr. RobertG, it’s always a pleasure to learn from the best. Thank you very much for your help. Warm regards, Quaresma