How do XContent and XForm relate in Base?

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.

Hello,

Always is a problem when dealing with the term Form. It means multiple things.

First, when opening Base there is the Form section. This is the container for your Forms for this Base file. You access that in a macro with:

Form = ThisComponent.getFormDocuments.getByName("FORM_NAME")

There is a similar container for reports.

Now once a Base Form is opened, with a macro you can access the internals of the form in real time - data present. This is done with:

Form = ThisComponent.DrawPage.Forms.getByName("INTERNAL_NAME")

Now a Base form can have one or many internal forms. On special occasion none. And each internal form can have sub forms and those sub sub form etc.

So access the container to open a form not currently opened and access the internal form to get at the data in real time.

ThisComponent varies depending upon where it is called from. It refers to the panel it was executed from. For some information please see → ThisDatabaseDocument vs ThisComponent?