Change the table referred to in the base form content with a macro

Hi! I hope someone can help me. I want to change the content of a form with a macro.
I have a form “Display”. Its ‘Form Properties-Data-Content’ box defines the content of the form to be a table “Table 1”. I am attempting to write a macro that will change this content from “Table1” to “Table2”.
I found on this site a solution to a similar enquiry ‘Change the base form sort property by macro’ and have experimented along the lines suggest there. But many attempts based around the lines shown below have failed.

oForm = ThisComponent.Drawpage.Forms.getByName(“Display”)

oForm.Content = “(”“Table2"”)"


The objection is “Property or method not found:Content”.

I have looked into the literature but can find no example where someone is changing the content of a form and am puzzled because if ‘Filter’ worked in the previous enquiry what should I use other than ‘Content’ here?
Can anyone give me a clue how to proceed?

Hello @baseplodder,

please try

Sub set_Form_Content( oForm As Object, iCommandType as Integer, sCommand As String )
REM <iCommandType>	: Member of 0=TABLE; 1=QUERY; 2=COMMAND.
REM <sCommand>		: Name of a Table or Query, or an SQL Select command.
	oForm.CommandType	= iCommandType
	oForm.Command		= sCommand
End Sub

Thank you Librebel - magnificent and without insider knowledge impossible to guess. Thank you also for the generality of the code. I am sure it will help many others.

You’re welcome @baseplodder :slight_smile: