Ask Your Question
0

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

asked 2017-08-29 12:47:03 +0200

baseplodder gravatar image

updated 2017-08-29 12:49:12 +0200

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

oForm.reload()

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?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2017-08-29 14:05:06 +0200

librebel gravatar image

Hello @baseplodder,

please try

Sub set_Form_Content( oForm As Object, iCommandType as Integer, sCommand As String )
REM <iCommandType>  : Member of com.sun.star.sdb.CommandType: 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
    oForm.reload()
End Sub
edit flag offensive delete link more

Comments

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.

baseplodder gravatar imagebaseplodder ( 2017-08-29 16:39:00 +0200 )edit

You're welcome @baseplodder :)

librebel gravatar imagelibrebel ( 2017-08-29 16:45:44 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2017-08-29 12:47:03 +0200

Seen: 74 times

Last updated: Aug 29 '17