Bizarre problem, which is perhaps due to ODBC rather than LO. (I am using LO Base on a Mac as a front end to an SQLite database.)
I have a control on a form into which, if I want to enter a new rather than an existing (numerical) value, this should be the next unused value in another table. Entering ‘0’ in this (formatted) field prompts a macro (attached to ‘Before Update’ or ‘After Update’ - there appears to be no difference) which successfully fetches this and returns the value to the control: relevant code below.
If oField.text = "0" then [Do things to get the required number] oField.text = Cstr(ReqdNo) oField.commit() endif
The required number displays in the control, but when the form moves to another record and back again, I find that the value ‘0’ has been entered. I have tried a variety of alternative ruses, e.g.
CtlView = oCurrentController.getControl(oField) CtlView.text = Cstr(ReqdNo)
oForm.updateRow(). The former made no difference, the latter seems regularly to return an SQL ‘Function sequence error.’
How can I force the value displayed on the form to be posted correctly to the underlying table? (If I type it in manually, it behaves exactly as it should.)