[SOLVED] Button to enable/disable allow modification of data
Posted: Thu Jan 23, 2020 1:27 pm
Hi,
I have a simple form for viewing, modifying and adding new records to a table. Due to the way that forms work it's all too easy for someone to accidentally change some data on a record with realising they are doing it.
What I would like to make the form more secure and more user-friendly is the option to turn on and off the allow modifications setting for the form.
So what I thought would work is to have the form's default setting to not allow modifications, then have 2 push buttons: one to change the setting to allow modifications; a second button to save changes and then change the setting back to do not allow modifications.
I've tried recording a macro turning the allow modifications on and off but when I assign this to a push button, it does not work - nothing happens basically. I have the macro assigned to the "Mouse button pressed" event.
The macro code is:
I have a simple form for viewing, modifying and adding new records to a table. Due to the way that forms work it's all too easy for someone to accidentally change some data on a record with realising they are doing it.
What I would like to make the form more secure and more user-friendly is the option to turn on and off the allow modifications setting for the form.
So what I thought would work is to have the form's default setting to not allow modifications, then have 2 push buttons: one to change the setting to allow modifications; a second button to save changes and then change the setting back to do not allow modifications.
I've tried recording a macro turning the allow modifications on and off but when I assign this to a push button, it does not work - nothing happens basically. I have the macro assigned to the "Mouse button pressed" event.
The macro code is:
Code: Select all
sub turnonmods2
rem ----------------------------------------------------------------------
rem define variables
dim document as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
rem ----------------------------------------------------------------------
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "FormProperties"
args1(0).Value = true
dispatcher.executeDispatch(document, ".uno:FormProperties", "", 0, args1())
end sub