Ask Your Question
0

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

asked 2020-09-04 17:23:20 +0100

Philip K gravatar image

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)?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2020-09-04 17:56:05 +0100

Ratslinger gravatar image

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

edit flag offensive delete link more

Comments

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()
Philip K gravatar imagePhilip K ( 2020-09-04 18:21:23 +0100 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2020-09-04 17:23:20 +0100

Seen: 21 times

Last updated: Sep 04