LO 6.4.3.2-snap1, Ubuntu 18.04 with all updates.
Hello,
I created a form with the wizard to add a new record to a table. I then added ‘Cancel’ and ‘Save’ buttons with the appropriate actions.
I use the code below to populate certain fields with default values. This works, when the form displays it shows the values I want. However, when the ‘Save’ button is clicked the values entered by the macro do not save into the table, only the data that has been manually entered is saved!
To this end I added the lines you see to set the focus to each control before I set the default values. Still, they do not save.
Is this a bug or have I missed a step? I will get over it by removing the default action from the ‘Save’ button and using SQL to update the table but this is surely not the way it should be?
sub StudentClassSetupNew(pEvent as object)
'### puts default values into new record
'### called from "Add New Class" button on
'### frm_StudentClass
Dim oFrm as object
Dim oDocCtl as object
Dim sSQL as string
oFrm = ThisComponent.Drawpage.Forms.getByName("NewClassForm")
oDocCtl = ThisComponent.getCurrentController()
'### bug in date field means we have to put in a dummy value first before the date we want
oDocCtl.getControl(oFrm.getByName("datClassDate")).setfocus()
oFrm.getbyname("datClassDate").text = "01/01/01"
oFrm.getbyname("datClassDate").text = format(now()+1,"Ddd dd Mmm YYYY")
oDocCtl.getControl(oFrm.getByName("timClassTime")).setfocus()
oFrm.getbyname("timClassTime").text = format(now(), "HH:MM")
oDocCtl.getControl(oFrm.getByName("fmtDuration")).setfocus()
oFrm.getbyname("fmtDuration").text =60
oDocCtl.getControl(oFrm.getByName("fmtFKPlanRef")).setfocus()
oFrm.getByName("fmtFKPlanRef").text = 0
'### set up listboxes
oDocCtl.getControl(oFrm.getByName("lstLang")).selectItemPos(0,true)
oDocCtl.getControl(oFrm.getByName("lstStatus")).selectItemPos(0,true)
oFrm = nothing
oDocCtl = nothing
end sub