Hello,
I try to safe a value from a form into a table when a new data set is created in another table. For this the “prior to reset” call is exactly what I need. The call of the macro is working like I need it.
In most of the manuals you can read:
Prior to reset
The Prior to reset event occurs before a form is reset. Returning True approves the reset, returning False cancels the operation.
A form is reset if one of the following conditions is met:
1. The user presses an (HTML) button that is defined as a reset button.
2. A new and empty record is created in a form that is linked to a data source. For example, in the last record, the Next Record button may be pressed.
BUT…
the values in the form are already reset when the macro is called. Is the name “prior” wrong or am I too stupid to use it?
'###### This Sub is called when a form field is changed and working fine
Sub Form_Articole_Code
DIM oDoc as Object
Dim oFormular as Object
Dim oArt as Object
Dim oSac as Object
Dim oCode as Object
Dim Nummer as Long
oDoc = thisComponent
oFormular = oDoc.drawpage
oArt = oFormular.forms.getByName("MainForm")
oSac = oArt.getByName("SubFormSac")
oCode = oArt.getByName("SubFormCodes")
'Some Code in between
oCode.reload
Nummer = oCode.getLong(3) + 1
oArt.updateLong(3, Nummer)
oArt.updateRow()
'###### here it is working but it creates problems
'###### when the user changes after values in the form again.
'###### Because of this I want to move the following 2 lines in the "prior to reset" Sub
'write back Nr in Code table
oCode.updateLong(3, Nummer)
oCode.updateRow()
End Sub
'### The sub is called when the Main Form (oArt) is reset
Sub Form_Articole_PriorToReset
DIM oDoc as Object
Dim oFormular as Object
Dim oArt as Object
Dim oCode as Object
Dim Nummer as Long
oDoc = thisComponent
oFormular = oDoc.drawpage
oArt = oFormular.forms.getByName("MainForm")
oCode = oArt.getByName("SubFormCodes")
'### here the values are already deleted
'write back Nr in Code table
oCode.reload 'added for testing
Nummer = oArt.getLong(3)
oCode.updateLong(3, Nummer)
oCode.updateRow()
End Sub
Thank you in advance for any help.