Hi,
I have a main form and a subform. I need to syncronize the subform when I make a change in a record of the main form.
Unfortunatelly I dont know much about macros and events. Is there anyone can help me?
Thanks in advance
[Solved] Subform synchronization
[Solved] Subform synchronization
Last edited by george++ on Sat Nov 10, 2012 11:08 pm, edited 1 time in total.
OpenOffice 3.3 on WindowsXP
Re: Subform synchronization
method #1: Go to another record and then back to the modified record.
#2: Add a push button to the subform with property "Action"="Refresh form".
#2: Add a push button to the subform with property "Action"="Refresh form".
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: Subform synchronization
Villeroy, thank you very much. The second method works like a charm!
Just for fine tuning:Is it possible to generate a "Refresh" action of the subform when a list box, from the main form, changes it's selection?
Just for fine tuning:Is it possible to generate a "Refresh" action of the subform when a list box, from the main form, changes it's selection?
OpenOffice 3.3 on WindowsXP
Re: Subform synchronization
The same 'Refresh form' action applied to a push-button on the SubForm will also process List Box selections on the MainForm. If you prefer a more automated approach, then you'll need a macro applied to an appropriate List Box Event. Here's a demo of both techniques:george++ wrote:Is it possible to generate a "Refresh" action of the subform when a list box, from the main form, changes it's selection?
http://forum.openoffice.org/en/forum/vi ... 13#p252113
...
AOO 4.1.x; LO 4.2.x; Windows 7/8 64-bit
Warning: Avoid embedded databases --> Solution: Adopt a portable 'split database' folder
Soli Deo gloria
Warning: Avoid embedded databases --> Solution: Adopt a portable 'split database' folder
Soli Deo gloria
Re: [Solved] Subform synchronization
Thank you again.
I looked into the code and although I am an experienced C++ programmer I feel helpless because I can't find where are the properties of an 'object' and what are represent.
Let's say:
I don't know, for example, that the object has a property named 'Source' (or method) and the 'Source' has a 'Model' and the 'Model' has a property named 'Parent' (or method)
For example, what represents the 'Model'?
I search to the Wiki section but I didn't find detailed explanations and answers to the questions above.
I don't know where to start.
I looked into the code and although I am an experienced C++ programmer I feel helpless because I can't find where are the properties of an 'object' and what are represent.
Let's say:
Code: Select all
oForm = oEvent.Source.Model.Parent
For example, what represents the 'Model'?
I search to the Wiki section but I didn't find detailed explanations and answers to the questions above.
I don't know where to start.
OpenOffice 3.3 on WindowsXP
Re: [Solved] Subform synchronization
I see that you've marked this thread 'Solved' so I presume you're happy with Villeroy's solution. That's excellent.
With reguard to your follow-up question about List Boxes, I presume from your response above that you're simply expressing an interest in the *ooBasic macro language or underlying UNO API -- in general -- because you're an experienced C++ programmer. I'll offer you some links (below) as food-for-thought on the topic, but I don't recommend learning anything about macros or objects in pursuit of an automated solution to your List Box question.
Concerning your List Box question: I assumed that you had tested the push-button solution with a List Box, so I offered the additional macro-driven solution in response. The macro was offered as a plug-in solution requiring no additional knowledge beyond built-in Base facilities. In other words, the manual push-button solution requires you to dive under-the-hood to assign an appropriate form-refresh 'action' while also placing the button on the appropriate SubForm using the Form Navigator. Likewise, a boilerplate macro requires you to copy&paste the macro to your Base (.odb) document, assign the macro to the designated 'event' on the Events tab of the List Box, and ensure the macro code reflects the correct SubForm 'name' as reflected in the Form Navigator. That's it. There's no intent to drive you into actual coding in a case like this. For example...
Given the following macro from the demo file:
As promised, some food-for-thought on macros. Note that Introduction into object inspection with MRI]object inspectors are available as add-ons or extensions:
With reguard to your follow-up question about List Boxes, I presume from your response above that you're simply expressing an interest in the *ooBasic macro language or underlying UNO API -- in general -- because you're an experienced C++ programmer. I'll offer you some links (below) as food-for-thought on the topic, but I don't recommend learning anything about macros or objects in pursuit of an automated solution to your List Box question.
Concerning your List Box question: I assumed that you had tested the push-button solution with a List Box, so I offered the additional macro-driven solution in response. The macro was offered as a plug-in solution requiring no additional knowledge beyond built-in Base facilities. In other words, the manual push-button solution requires you to dive under-the-hood to assign an appropriate form-refresh 'action' while also placing the button on the appropriate SubForm using the Form Navigator. Likewise, a boilerplate macro requires you to copy&paste the macro to your Base (.odb) document, assign the macro to the designated 'event' on the Events tab of the List Box, and ensure the macro code reflects the correct SubForm 'name' as reflected in the Form Navigator. That's it. There's no intent to drive you into actual coding in a case like this. For example...
Given the following macro from the demo file:
Code: Select all
Sub RefreshForm (oEvent as Object) 'Form > List Box > Events > Execute action oForm = oEvent.Source.Model.Parent oEvent.Source.Model.commit() 'save the List Box selection to the host data-Form 'save all changes to the MainForm's Table... compiler bug doesn't allow comments on an IF-THEN-ELSE line IF oForm.isnew THEN oForm.insertRow() ELSE oForm.updateRow() oForm.GetByName("SubForm1").reload 'reload the SubForm's individually to avoid jumping to the first record oForm.GetByName("SubForm2").reload 'reload the SubForm's individually to avoid jumping to the first record End Sub
- 1. copy this macro to your Base (.odb) file as shown in the demo (.odb) file
2. assign the macro to the event indicated in the macro comment: Form > List Box > Events tab > Execute action
3. replace the name of your SubForm as appropriate in the macro code; your SubForm name is determined by opening the Form Navigator
4. delete the last line of the macro if you don't have multiple SubForms to refresh
Code: Select all
Sub RefreshForm (oEvent as Object) 'Form > List Box > Events > Execute action oForm = oEvent.Source.Model.Parent oEvent.Source.Model.commit() 'save the List Box selection to the host data-Form 'save all changes to the MainForm's Table... compiler bug doesn't allow comments on an IF-THEN-ELSE line IF oForm.isnew THEN oForm.insertRow() ELSE oForm.updateRow() oForm.GetByName("SubForm").reload 'reload the SubForm's individually to avoid jumping to the first record End Sub
As promised, some food-for-thought on macros. Note that Introduction into object inspection with MRI]object inspectors are available as add-ons or extensions:
Last edited by DACM on Sun May 04, 2014 3:25 am, edited 1 time in total.
AOO 4.1.x; LO 4.2.x; Windows 7/8 64-bit
Warning: Avoid embedded databases --> Solution: Adopt a portable 'split database' folder
Soli Deo gloria
Warning: Avoid embedded databases --> Solution: Adopt a portable 'split database' folder
Soli Deo gloria
Re: [Solved] Subform synchronization
Thanks a lotI'll offer you some links (below) as food-for-thought on the topic, but I don't recommend learning anything about macros or objects in pursuit of an automated solution to your List Box question.
OpenOffice 3.3 on WindowsXP