@Villeroy , great job!
Thanks to all participants for a very interesting topic!
The attached example is based on the approach suggested by @Villeroy in this topic, using the FormController object. The macros from Module2 are from @Villeroyās example.
After opening the FormFocus form, you need to click the Start
button. After that, events of getting focus by top-level forms will be tracked. The ID field (if it exists in the form) is taken when the form gets focus.
Macros should also work in Standalone form. To process the subforms, you need to slightly modify the SetFormControllerListener macro code.
FormFocus.odb (36.2 KB)
Have opened the example. There is set onFocus to every control, not only to the form. if there is any other macro planned for onFocus of a control it will be lost.
There must be a event for forms only. Navigationbar at the bottom of the forms register this event and change from form ton subform without any focus event of all of the controls ā¦
Thank you @Ratslinger,
No, up to now there is no solution Please refer also to the reply from @RobertG.
What I do not understand: Jumping between the grey and both orange parts (Forms / TableControl), the content in the navigation bar changes showing the actual record number etc. So there must be an event signalizing such changes to LibreOffice.
Thank you very much @sokol92!
I started the .odb and pressed the start button. After that, the info (green fields) for form āERPā are shown. Thatās fine!
Iām not sure, that I used the START-button correctly; here it hides the navigation bar, which should not happen in the final solution. If I didnāt misunderstand the actual version, for the following issues Iād need enhancements:
- Info after changes in form āOutgoingā are not shown so far.
- Info after changes in form āProviderā are not shown so far.
- Scrolling through the form āProviderā should not reset the START-Button.
- The START-Button should not be necessary. This means, jumping through the three forms should trigger the macro code directly.
Do you think, this is possible?
I will prepare a new version taking into account your wishes no later than tomorrow.
That event triggers āBefore Record Changeā and then āAfter Record Changeā
Thanks a lot @sokol92, looks perfect! I have to understand your solution and to transform it into my application; this may take longer than tomorrow due to other obligations. After that, Iāll come back to you.
Thank you so far!
Thanks again,
Iām trying to understand the macros:
- Am I right that in you3 FormFocus3.odb only the macros āModule3ā are actual for your solution? If so, Iād delete Module1 and Module2 for my version.
- In the code "Module3) I found Sub DocFormLoaded(oEvent) and Sub DocFormUnLoaded(oEvent), both are triggered in Menu > Extras > Customize > Event. The Form itself has Macros DocFormLoaded and FormUnLoaded (ref. picture):
these makros I donāt find. Are you OK to delete both connections?
Hello!
Module3 uses the getParentObject
function from Module2.
I apologize - these are traces of my experiments. You need to remove the handlers of these events using the appropriate button.
No need for any apology at all. I am so grateful for your amazing support!
I have reduced the database FormFocus 20230226 E.odb (16.8 KB) for my further research.
- During testing, I have been a bit confused: After opening the form, the green field are empty (same in your version). Would it be possible, to set the focus on start to the first form (here āProviderā) and to disply information in green fields from there?
- āModule3ā lines 87ā¦90 seem to be empty, but deleting the lines, seems to produce an error.
Thank you!
Letās try changing one macro:
Sub DocFormLoaded(oEvent)
Dim oDoc, oForm
oDoc=oEvent.Source
If oDoc.CurrentController.isFormDesignMode Then Exit Sub
SetFormControllerListeners oDoc
oForm=oDoc.DrawPage.Forms.getByName("Provider")
FillMainForm oForm
oDoc.CurrentController.getControl(oForm.getByName("fmtID")).setFocus
End Sub
For any listener in Basic, we must create macros to handle all possible events, regardless of whether we are going to respond to these events.