This is academic. The macro below shows three ways to get to a form in Base:
Sub CompleteURL(Event As Object)
Dim Form As Object
Dim Field As Object
' Works when called by button
Form = Event.Source.Model.Parent
' Returns XInterface/XForm
' Works when called by button, but cannot find "Passwords". Must use "MainForm"
'Form = ThisComponent.DrawPage.Forms.getByName("MainForm")
' Returns XForm
' Works when called from BASIC IDE
'Form = ThisComponent.getFormDocuments.getByName("Passwords")
' Returns XContent
' Does IsForm property come from com.sun.star.comp.sdb.Content implementation?
Field = Form.getByName("txtLoginURL")
Field.Text = "https://" & Field.Text
End Sub
I know I can read yet another day on the UNO API, but would someone have insight on these access methods, namely:
What is the connection between the comp.sdb.Content/XContent class/interface and the comp.forms.ODatabaseForm/XForm class/interface? Either will return detailed information about what appears to me, the front-end user, to be the same form object, but obviously they are very different creatures. Is one the content as it is seen in the Base form pane and the other the form, as it were, itself? If so, is there any way to bridge them…say, to call upon a form by its form pane name ultimately using DrawPage.Forms or get to the form itself via the Content object?
Also, I notice that ThisComponent seems to be different depending on whether the macro is called from the BASIC IDE or from a form button. I sort of thought the idea behind ThisComponent was to be the same in both contexts? Any comments?
PS: I realize that the macro hasn’t committed the field, so it won’t be persisted as such. And, yes, I do use a (an Access) database for passwords…it just points to an entry line in a pen-and-paper ledger.