[Solved] Refresh-form macro disturbing Cascading listboxes

Creating and using forms
Post Reply
Yann
Posts: 26
Joined: Wed Mar 04, 2015 11:04 am

[Solved] Refresh-form macro disturbing Cascading listboxes

Post by Yann »

I used this macro to substitute for the refresh-button,
and it interrupted the behaviour of the cascading listboxes - they stopped filtering each other

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("Products").reload 'reload the SubForm's individually to avoid jumping to the first record
End Sub
Attachments
MULTI_CRITERIA_SEARCH %281%29.odb
(85.79 KiB) Downloaded 204 times
Last edited by Yann on Fri May 08, 2015 2:35 pm, edited 1 time in total.
OpenOffice 4.4.1 on Windows 8
User avatar
MTP
Volunteer
Posts: 1620
Joined: Mon Sep 10, 2012 7:31 pm
Location: Midwest USA

Re: Refresh-form macro disturbing Cascading listboxes

Post by MTP »

I suspect the problem is that the button "action" of "refresh form" refreshes both the form and the listboxes. The macro "reload form" only refreshes the form and the listboxes have to be refreshed separately.

If the macro is triggered by the listbox events "item status changed" this should work for all the listboxes on the subform "Filter":

Code: Select all

Sub RefreshForm (oEvent as Object) 
   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("Products").reload 'reload the SubForm's individually to avoid jumping to the first record
   
   REM Listboxes have to be refreshed individually
   oForm.lstF_ID_GROUP.refresh
   oForm.lstF_ID_INGREDIENT.refresh
   oForm.lstF_ID_KEYWORD.refresh
   oForm.lstF_ID_INDICATION.refresh
   oForm.lstF_ID_PURPOSE.refresh
   oForm.lstF_ID_BODYPART.refresh
   oForm.lstF_ID_BODYTYPE.refresh

   oForm.parent.lstF_ID_SYSTEM.refresh
End Sub
A different macro (or a IF statement checking the form name) would be needed for the SYSTEM listbox that is on a different subform. Let us know if that helps.
OpenOffice 4.1.1 on Windows 10, HSQLDB 1.8 split database
Yann
Posts: 26
Joined: Wed Mar 04, 2015 11:04 am

Re: Refresh-form macro disturbing Cascading listboxes

Post by Yann »

All works perfectly now !
(I moved the systems listbox with all the rest, like you suggested)
OpenOffice 4.4.1 on Windows 8
Post Reply