Set a filter on a LO Base form when opening it from another

I want a macro attached to one form to open another with a restricted range of values (i.e. by setting a filter on it).

I can open the form successfully:

	WantedForm = ThisDatabaseDocument.FormDocuments.getByName("Form-A")
	WantedForm.open()

But then I want to set a filter. WantedForm.filter = ("[Table-A].[Field1] = " & FilterVal) is not recognised as a method. The main content of the form is of course named “MainForm” - but how do I address the filter property of the main form (assuming WantedForm.reload() at the end)?

Hello,

You are having the problem because of trying to access a newly opened form but having a handle on it yet. You need access after opening the form:

Rem Get access to newly opened form
myDoc = ThisDatabaseDocument.FormDocuments.getbyname( "Form-A" )
oObj1 = myDoc.getComponent().getDrawPage().getForms().getByName("YOUR_INTERNAL_FORM_NAME")
Wait 100

You can get a working sample of this from my answer in this post → Base Macro - Click on Table Row to Open Record

Quick and effective answer to a quick question: reliable as ever - thank you so much! For the possible convenience of others, here is the working code (WantedForm and oForm are defined as Objects, VessFilter is a String obtained from the calling form):

WantedForm = ThisDatabaseDocument.FormDocuments.getByName("Form-A")
WantedForm.open()
oForm = WantedForm.getComponent().getDrawPage().getForms().getByName("MainForm")
Wait 100
oForm.filter = ("[Table-A].[Field1] = " & VessFilter)
oForm.reload()