Ask Your Question

Remove button permanently by macro

asked 2020-06-11 05:05:09 +0100

gkick gravatar image


I have come across a number of examples as how to toggle visibility/enable properties for buttons and other controls all of which work well - until the database is restarted.

So for example, I have a database with demo data, sort of like a tutorial. On the System Config form I have a button titled remove demo data, which runs a simple script clearing all the tables, resetting counters etc.

Once all of that is accomplished I would like to "permanently" hide or delete the button via code to prevent someone from clicking the button again thus destroying their own data. Can this be done?


edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2020-06-11 19:02:52 +0100

Ratslinger gravatar image


The only way to "permanently" do something is to actually remove (delete) the control. This is not straightforward.

You can remove a control (shape) from the drawpage but it is only until you open the form again. To completely delete it you must open the form in edit mode. This can be done with:

ThisDatabaseDocument.FormDocuments.getbyname( "YOUR_FORM" ).openDesign

Next you need to find and delete the control. Code for that can be found in the answer by @JohnSUN in this post -> Macros and deleting

Then Save & close the form. Can do with macros. Sample code in this post -> is it possible to save and reopen a file from a macro

An alternative may be to remove the macro from the button event and then simply hide the button. Code to alter/remove macros from events can be found in the sample in my answer here -> How to access the settings under the 'Events' tab of a form control to get / set the routines?. There is also a link to the originating code.

edit flag offensive delete link more


Thank you, much appreciated!

gkick gravatar imagegkick ( 2020-06-14 08:11:00 +0100 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2020-06-11 05:05:09 +0100

Seen: 57 times

Last updated: Jun 11 '20