listboxformsqllist sourceMarc SanthoffHow can I change the SQL list source of a ListBox?
A query (SQL) based listbox has a fixed SQL statement for it's source.
Sometimes it is useful to change this statement by code, e.g. when using one form with different queries.
Sub changeLBSource
' caution: if you change like this and then save the form
' the SQL statement filled in when designing the form is
' overwritten with the new one, your code should hold both of them!
dim oDoc as object, oForm as object
dim oListboxModel as object
dim ssql(0) as string
oDoc = ThisComponent
oForm = oDoc.DrawPage.Forms(0)
oListboxModel = oForm.getByName("ListBox")
ssql(0) = "select ""name"", ""ID"" from ""color"""
oListboxModel.ListSource() = ssql()
oListboxModel.refresh()
End Sub
Initial version