[Solved] Bound field not updated at listbox change

Creating and using forms
Post Reply
User avatar
entfe001
Posts: 2
Joined: Fri Jan 16, 2009 10:32 am

[Solved] Bound field not updated at listbox change

Post by entfe001 »

I'm currently implementing a Base form which has a second listbox contents dependant from the selection on the first one. Googling around I've reached to implement the following code (txtfamilia is the first listbox and txtcicle the second):

Code: Select all

Sub FiltraCiclePerFamilia(listbox As Object, familia As String)
	Dim lbSQL(0) As String
	
	lbSQL(0) = "SELECT nom, codi FROM cicle"
	
	'Filter only if an option had been picked on the first listbox,
	'otherwise show up all possibilities
	If familia <> "" Then
		lbSQL(0) = lbSQL(0) & " WHERE familia = '" & familia & "'"
	End If
	
	MsgBox familia	'For debugging purposes
	
	'Update listbox contents
	listbox.ListSource = lbSQL
	listbox.refresh()
	
End Sub

'Called on first listbox change
Sub ActualitzaCicles(oEv As Object)
	Dim form As Object
	form = oEv.Source.Model.Parent
	
	Dim lbxCicle As Object
	Dim familia As String
	
	lbxCicle = form.getbyname("txtcicle")
	familia = form.getbyname("txtfamilia").BoundField.getString()
	
	MsgBox form.getbyname("txtfamilia").CurrentValue	'For debugging purposes
	
	FiltraCiclePerFamilia(lbxCicle, familia)
	
End Sub
The problem I encountered is that the CurrentValue and the BoundField are not always syncronized, i.e. when the two debugging message boxes show up on listbox change, the showing name on the listbox is the recently picked one but the BoundField is still the old one. So, with this code the second listbox is wrongly filled.

Is this a bug or there is something that I must do manually to syncronize the BoundField?

I'm using OOo 3.0.0 from Fedora 10 repository and working on a remote PostgreSQL database.

Thank you in advance for your attention.
OOo 3.0.X on Fedora other
User avatar
entfe001
Posts: 2
Joined: Fri Jan 16, 2009 10:32 am

Re: [SOLVED] Bound field not updated at listbox change

Post by entfe001 »

Well, I finally found out that I had to do a .commit() on the listbox to force the synchronization.
OOo 3.0.X on Fedora other
Post Reply