[Solved] Cannot change ListSource property of table column

Creating and using forms
Post Reply
StephanH2
Posts: 7
Joined: Mon Dec 30, 2013 4:41 pm

[Solved] Cannot change ListSource property of table column

Post by StephanH2 »

Dear all,

I am once again desperately looking for help because I don't understand the reason for the following problem. I am trying to change the ListSource property of a column within a table in a form. The table is filled by an SQL query and I would like to change the SQL query based on an input field holding a year information.

I can change the "Label" property of the field just to make sure that I am correctly addressing the column (which works), but I get an error when trying to access the ListSource property, I don't get an error when trying to access the ListSource(0) property as shown below but the content of that property simply does not change at all.

A similar topic has been discussed at http://de.openoffice.info/viewtopic.php?f=18&t=48100 but somehow this does not work for me.

Is there anybody who can help me out with this? Thanks in advance for your help, also if you just point me into a specific direction. Best, Stephan

Code: Select all

sub Filter_setzen_jahr

   Dim oSuchFeld as variant
   Dim oTypFeld as variant
   Dim oDoc as variant
   Dim oFormMain as variant
   Dim oFormExtrakosten as variant
   Dim oFormArbeitsstunden as variant
   Dim sJahr as variant
   Dim oTblGetraenkeabrechnung as variant
   Dim oSpalteArt as variant
   Dim sSource as variant

   oDoc = ThisComponent
   oFormMain = oDoc.DrawPage.Forms.GetByName("MainForm")
   oSuchFeld = oFormMain.getByName("numJahr")
   sJahr = oSuchFeld.CurrentValue

   oFormGetraenkeabrechnung = oFormMain.GetByName("frmGetraenkeabrechnung")

   oTblGetraenkeabrechnung = oFormGetraenkeabrechnung.getByName("tblGetraenkeabrechnung")
   oSpalteArt = oTblGetraenkeabrechnung.getByName("txtGetraenkeArtAuswahl")
'   this does not make a difference: sSource = "SELECT ""art"",""id"" FROM ""tcg_getraenke"" WHERE ""jahr""=" +sJahr+ " ORDER BY ""art"""
   sSource = "SELECT art,id FROM tcg_getraenke WHERE jahr=" +sJahr+ " ORDER BY art"
'   the following line has no effect
   oSpalteArt.ListSource(0) = sSource
   oSpalteArt.Label = sJahr
   oSpalteArt.refresh

   oFormGetraenkeabrechnung.filter = "YEAR(datum) LIKE '%" +sJahr+ "%'"
   oFormGetraenkeabrechnung.ApplyFilter=true
   oFormGetraenkeabrechnung.reload()
     
end sub
Last edited by StephanH2 on Fri Jan 23, 2015 10:37 pm, edited 1 time in total.
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: cannot change ListSource property of table column

Post by Villeroy »

The grid control is not bound to anything. A grid control is a container for bound controls (text, list, combo, date boxes etc.) so you can see more than one record at a time. Get the property window of a "table column" and the property window refers to a text, list, combo, date box.
So your "txtGetraenkeArtAuswahl" is a list box and the ListSource property refers to a hard coded list source of an unbound list box. You can type in ListSource arrays on the general tab of the properties window. For a bound list box control you need to set other properties.
 Edit: It's the "Command" property 
What you try to do here can be done without silly Basic code (I think).
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
StephanH2
Posts: 7
Joined: Mon Dec 30, 2013 4:41 pm

Re: cannot change ListSource property of table column

Post by StephanH2 »

Dear Villeroy,

could you then please explain to me how to set my properties to get a bound list box control? Yes, you are right, I can type the ListSource property in by hand but it is supposed to change dynamically whenever the field sJahr is changed.

Thank you
Stephan
OpenOffice 4.0 on Win7
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: cannot change ListSource property of table column

Post by Villeroy »

Don't you use MRI? Why not? It's the "Command" property.
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
StephanH2
Posts: 7
Joined: Mon Dec 30, 2013 4:41 pm

Re: cannot change ListSource property of table column

Post by StephanH2 »

Dear Villeroy,

thank you again for your fast reply. I am not programming to much on openoffice, therefore I am not familiar with all the useful features. Thank you for pointing out MRI, I have successfully installed this extension and I have analyzed the column oSpalteArt for which I would like to change the ListSource property dynamically. Please find the MRI output below. However, I cannot find a "command" property nor is it clear to me, what you are suggesting. Would you have the time to explain to me what you mean in more detail? Thank you in adance for your help

Stephan

Properties:

Code: Select all

(Name)                    (Value Type)                    (Value)             (Info.)   (Attr.)                       (Handle)  
Align                     short                           -void-                        Maybevoid,Bound,Maybedefault   63  
AllItems                  [].beans.Pair<string,string>    -Sequence-          Pseud     Read_Only                          
BoundColumn               short                           1                             Maybevoid,Bound               10000  
BoundField                .beans.XPropertySet             -INTERFACE-                   Read_Only,Bound,Transient     10001  
ClassId                   short                           6                             Read_Only,Transient           10002  
ColumnServiceName         string                          com.sun.star.fo...            Read_Only                     205  
ContextWritingMode        short                           4                             Bound,Transient,Maybedefault  10003  
ControlTypeinMSO          short                           0                             Bound                         10004  
CurrentValue              any                                                 Pseud     Read_Only                          
DataField                 string                          getraenke_id                  Bound                         10005  
DataFieldProperty         string                          SelectedItems                 Read_Only,Transient           10006  
DefaultControl            string                          com.sun.star.fo...            Bound,Maybedefault            10007  
DefaultSelection          []short                         -SEQUENCE-                    Bound                         10008  
Delegator                 .uno.XInterface                                     Pseud     WriteOnly                          
Enabled                   boolean                         True                          Bound,Maybedefault            10009  
FontCharWidth             float                           0.0                           Bound,Maybedefault            10010  
FontKerning               boolean                         False                         Bound,Maybedefault            10011  
FontOrientation           float                           0.0                           Bound,Maybedefault            10012  
FontPitch                 short                           0                             Bound,Maybedefault            10013  
FontType                  short                           0                             Bound,Maybedefault            10014  
FontWidth                 short                           0                             Bound,Maybedefault            10015  
HelpText                  string                          ""                            Bound,Maybedefault            10016  
HelpURL                   string                          ""                            Bound,Maybedefault            10017  
Hidden                    boolean                         False                         Bound,Maybedefault            161  
ImplementationId          []byte                          -SEQUENCE-          Pseud     Read_Only                          
ImplementationName        string                          -Error-             Pseud     Read_Only                          
InputRequired             boolean                         True                          Bound                         10018  
ItemCount                 long                            18                  Attr.     Read_Only                          
ItemSeparatorPos          short                           -void-                        Maybevoid,Bound,Maybedefault  10019  
Label                     string                          art                           Bound                          50  
LineCount                 short                           15                            Bound,Maybedefault            10020  
ListEntrySource           .form.binding.XListEntrySource  -void-              Pseud                                        
ListSource                []string                        -Sequence-                    Bound                         10021  
ListSourceType            .form.ListSourceType            SQL                           Bound                         10022  
MouseWheelBehavior        short                           1                             Bound,Maybedefault            10023  
MultiSelectionSimpleMode  boolean                         True                          Bound,Maybedefault            10024  
Name                      string                          txtGetraenkeArt...            Bound                         10025  
NativeWidgetLook          boolean                         False                         Bound,Transient               10026  
ObjIDinMSO                unsigned short                  65535                         Bound                         10027  
Parent                    .uno.XInterface                 -INTERFACE-         Pseud                                        
PropertySetInfo           .beans.XPropertySetInfo         -INTERFACE-         Pseud     Read_Only                          
PropertyToDefault         string                                              Ignored                                      
PropertyValues            [].beans.PropertyValue          -Sequence-                                                       
ReadOnly                  boolean                         False                         Bound,Maybedefault            10028  
ReferenceDevice           .awt.XDevice                    -void-                        Bound,Transient,Maybedefault  10029  
SelectedItems             []short                         -SEQUENCE-                    Bound,Maybedefault            10030  
ServiceName               string                          stardiv.one.for...  Pseud     Read_Only                          
StringItemList            []string                        -Sequence-                    Bound                         10031  
SupportedServiceNames     []string                        -Error-             Pseud     Read_Only                          
Tag                       string                          ""                            Bound                         10032  
Types                     []type                          -Sequence-          Pseud     Read_Only                          
Validator                 .form.validation.XValidator     -void-              Pseud                                        
ValueBinding              .form.binding.XValueBinding     -Error-             Pseud                                        
ValueItemList             []string                        -Sequence-                    Read_Only,Bound,Transient     10033  
Width                     long                            228                           Maybevoid,Bound,Maybedefault   42  
WritingMode               short                           4                             Bound,Maybedefault            10034  
Methods:

Code: Select all

(Name)                               (Arguments)                                         (Return Type)                   (DeclaringClass)                              (Exceptions)  
acquire                              ()                                                  void                            .uno.XInterface                                 
addEventListener                     ( [in] .lang.XEventListener xListener )             void                            .lang.XComponent                              .uno.RuntimeException  
addFormComponentValidityListener     ( [in] .form.validation.XFormComponentValidityListener Listener )  void                            .form.validation.XValidatableFormComponent    .lang.NullPointerException  
addItemListListener                  ( [in] .awt.XItemListListener Listener )            void                            .awt.XItemList                                  
addPropertiesChangeListener          ( [in] []string aPropertyNames, [in] .beans.XPropertiesChangeListener xListener )  void                            .beans.XMultiPropertySet                      .uno.RuntimeException  
addProperty                          ( [in] string Name, [in] short Attributes, [in] any DefaultValue )  void                            .beans.XPropertyContainer                     .beans.PropertyExistException, .beans.IllegalTypeException, .lang.IllegalArgumentException  
addPropertyChangeListener            ( [in] string aPropertyName, [in] .beans.XPropertyChangeListener xListener )  void                            .beans.XPropertySet                           .beans.UnknownPropertyException, .lang.WrappedTargetException, .uno.RuntimeException  
addRefreshListener                   ( [in] .util.XRefreshListener l )                   void                            .util.XRefreshable                              
addResetListener                     ( [in] .form.XResetListener aListener )             void                            .form.XReset                                    
addSQLErrorListener                  ( [in] .sdb.XSQLErrorListener Listener )            void                            .sdb.XSQLErrorBroadcaster                       
addUpdateListener                    ( [in] .form.XUpdateListener aListener )            void                            .form.XUpdateBroadcaster                        
addVetoableChangeListener            ( [in] string PropertyName, [in] .beans.XVetoableChangeListener aListener )  void                            .beans.XPropertySet                           .beans.UnknownPropertyException, .lang.WrappedTargetException, .uno.RuntimeException  
allEntriesChanged                    ( [in] .lang.EventObject Source )                   void                            .form.binding.XListEntryListener                
commit                               ()                                                  boolean                         .form.XBoundComponent                           
createClone                          ()                                                  .util.XCloneable                .util.XCloneable                                
dispose                              ()                                                  void                            .lang.XComponent                              .uno.RuntimeException  
disposing                            ( [in] .lang.EventObject Source )                   void                            .lang.XEventListener                          .uno.RuntimeException  
entryChanged                         ( [in] .form.binding.ListEntryEvent Source )        void                            .form.binding.XListEntryListener                
entryRangeInserted                   ( [in] .form.binding.ListEntryEvent Source )        void                            .form.binding.XListEntryListener                
entryRangeRemoved                    ( [in] .form.binding.ListEntryEvent Source )        void                            .form.binding.XListEntryListener                
firePropertiesChangeEvent            ( [in] []string aPropertyNames, [in] .beans.XPropertiesChangeListener xListener )  void                            .beans.XMultiPropertySet                      .uno.RuntimeException  
getAllItems                          ()                                                  [].beans.Pair<string,string>    .awt.XItemList                                  
getCurrentValue                      ()                                                  any                             .form.validation.XValidatableFormComponent      
getFastPropertyValue                 ( [in] long nHandle )                               any                             .beans.XFastPropertySet                       .beans.UnknownPropertyException, .lang.WrappedTargetException, .uno.RuntimeException  
getImplementationId                  ()                                                  []byte                          .lang.XTypeProvider                           .uno.RuntimeException  
getImplementationName                ()                                                  string                          .lang.XServiceInfo                            .uno.RuntimeException  
getItemData                          ( [in] long Position )                              any                             .awt.XItemList                                .lang.IndexOutOfBoundsException  
getItemImage                         ( [in] long Position )                              string                          .awt.XItemList                                .lang.IndexOutOfBoundsException  
getItemText                          ( [in] long Position )                              string                          .awt.XItemList                                .lang.IndexOutOfBoundsException  
getItemTextAndImage                  ( [in] long Position )                              .beans.Pair<string,string>      .awt.XItemList                                .lang.IndexOutOfBoundsException  
getListEntrySource                   ()                                                  .form.binding.XListEntrySource  .form.binding.XListEntrySink                    
getName                              ()                                                  string                          .container.XNamed                               
getParent                            ()                                                  .uno.XInterface                 .container.XChild                               
getPropertyDefault                   ( [in] string aPropertyName )                       any                             .beans.XPropertyState                         .beans.UnknownPropertyException, .lang.WrappedTargetException  
getPropertySetInfo                   ()                                                  .beans.XPropertySetInfo         .beans.XMultiPropertySet                      .uno.RuntimeException  
getPropertySetInfo                   ()                                                  .beans.XPropertySetInfo         .beans.XPropertySet                           .uno.RuntimeException  
getPropertyState                     ( [in] string PropertyName )                        .beans.PropertyState            .beans.XPropertyState                         .beans.UnknownPropertyException  
getPropertyStates                    ( [in] []string aPropertyName )                     [].beans.PropertyState          .beans.XPropertyState                         .beans.UnknownPropertyException  
getPropertyValue                     ( [in] string PropertyName )                        any                             .beans.XPropertySet                           .beans.UnknownPropertyException, .lang.WrappedTargetException, .uno.RuntimeException  
getPropertyValues                    ( [in] []string aPropertyNames )                    []any                           .beans.XMultiPropertySet                      .uno.RuntimeException  
getPropertyValues                    ()                                                  [].beans.PropertyValue          .beans.XPropertyAccess                          
getServiceName                       ()                                                  string                          .io.XPersistObject                              
getSomething                         ( [in] []byte aIdentifier )                         hyper                           .lang.XUnoTunnel                              .uno.RuntimeException  
getSupportedServiceNames             ()                                                  []string                        .lang.XServiceInfo                            .uno.RuntimeException  
getTypes                             ()                                                  []type                          .lang.XTypeProvider                           .uno.RuntimeException  
getValidator                         ()                                                  .form.validation.XValidator     .form.validation.XValidatable                   
getValueBinding                      ()                                                  .form.binding.XValueBinding     .form.binding.XBindableValue                    
insertItem                           ( [in] long Position, [in] string ItemText, [in] string ItemImageURL )  void                            .awt.XItemList                                .lang.IndexOutOfBoundsException  
insertItemImage                      ( [in] long Position, [in] string ItemImageURL )    void                            .awt.XItemList                                .lang.IndexOutOfBoundsException  
insertItemText                       ( [in] long Position, [in] string ItemText )        void                            .awt.XItemList                                .lang.IndexOutOfBoundsException  
isValid                              ()                                                  boolean                         .form.validation.XValidatableFormComponent      
loaded                               ( [in] .lang.EventObject aEvent )                   void                            .form.XLoadListener                             
modified                             ( [in] .lang.EventObject aEvent )                   void                            .util.XModifyListener                           
onRowSetChanged                      ( [in] .lang.EventObject i_Event )                  void                            .sdb.XRowSetChangeListener                      
propertyChange                       ( [in] .beans.PropertyChangeEvent evt )             void                            .beans.XPropertyChangeListener                .uno.RuntimeException  
queryAdapter                         ()                                                  .uno.XAdapter                   .uno.XWeak                                    .uno.RuntimeException  
queryAggregation                     ( [in] type aType )                                 any                             .uno.XAggregation                             .uno.RuntimeException  
queryInterface                       ( [in] type aType )                                 any                             .uno.XInterface                               .uno.RuntimeException  
read                                 ( [in] .io.XObjectInputStream InStream )            void                            .io.XPersistObject                            .io.IOException  
refresh                              ()                                                  void                            .util.XRefreshable                              
release                              ()                                                  void                            .uno.XInterface                                 
reloaded                             ( [in] .lang.EventObject aEvent )                   void                            .form.XLoadListener                             
reloading                            ( [in] .lang.EventObject aEvent )                   void                            .form.XLoadListener                             
removeAllItems                       ()                                                  void                            .awt.XItemList                                  
removeEventListener                  ( [in] .lang.XEventListener aListener )             void                            .lang.XComponent                              .uno.RuntimeException  
removeFormComponentValidityListener  ( [in] .form.validation.XFormComponentValidityListener Listener )  void                            .form.validation.XValidatableFormComponent    .lang.NullPointerException  
removeItem                           ( [in] long Position )                              void                            .awt.XItemList                                .lang.IndexOutOfBoundsException  
removeItemListListener               ( [in] .awt.XItemListListener Listener )            void                            .awt.XItemList                                  
removePropertiesChangeListener       ( [in] .beans.XPropertiesChangeListener xListener )  void                            .beans.XMultiPropertySet                      .uno.RuntimeException  
removeProperty                       ( [in] string Name )                                void                            .beans.XPropertyContainer                     .beans.UnknownPropertyException, .beans.NotRemoveableException  
removePropertyChangeListener         ( [in] string aPropertyName, [in] .beans.XPropertyChangeListener aListener )  void                            .beans.XPropertySet                           .beans.UnknownPropertyException, .lang.WrappedTargetException, .uno.RuntimeException  
removeRefreshListener                ( [in] .util.XRefreshListener l )                   void                            .util.XRefreshable                              
removeResetListener                  ( [in] .form.XResetListener aListener )             void                            .form.XReset                                    
removeSQLErrorListener               ( [in] .sdb.XSQLErrorListener Listener )            void                            .sdb.XSQLErrorBroadcaster                       
removeUpdateListener                 ( [in] .form.XUpdateListener aListener )            void                            .form.XUpdateBroadcaster                        
removeVetoableChangeListener         ( [in] string PropertyName, [in] .beans.XVetoableChangeListener aListener )  void                            .beans.XPropertySet                           .beans.UnknownPropertyException, .lang.WrappedTargetException, .uno.RuntimeException  
reset                                ()                                                  void                            .form.XReset                                    
setDelegator                         ( [in] .uno.XInterface pDelegator )                 void                            .uno.XAggregation                             .uno.RuntimeException  
setFastPropertyValue                 ( [in] long nHandle, [in] any aValue )              void                            .beans.XFastPropertySet                       .beans.UnknownPropertyException, .beans.PropertyVetoException, .lang.IllegalArgumentException, .lang.WrappedTargetException, .uno.RuntimeException  
setItemData                          ( [in] long Position, [in] any ItemData )           void                            .awt.XItemList                                .lang.IndexOutOfBoundsException  
setItemImage                         ( [in] long Position, [in] string ItemImageURL )    void                            .awt.XItemList                                .lang.IndexOutOfBoundsException  
setItemText                          ( [in] long Position, [in] string ItemText )        void                            .awt.XItemList                                .lang.IndexOutOfBoundsException  
setItemTextAndImage                  ( [in] long Position, [in] string ItemText, [in] string ItemImageURL )  void                            .awt.XItemList                                .lang.IndexOutOfBoundsException  
setListEntrySource                   ( [in] .form.binding.XListEntrySource Source )      void                            .form.binding.XListEntrySink                    
setName                              ( [in] string aName )                               void                            .container.XNamed                               
setParent                            ( [in] .uno.XInterface Parent )                     void                            .container.XChild                             .lang.NoSupportException  
setPropertyToDefault                 ( [in] string PropertyName )                        void                            .beans.XPropertyState                         .beans.UnknownPropertyException  
setPropertyValue                     ( [in] string aPropertyName, [in] any aValue )      void                            .beans.XPropertySet                           .beans.UnknownPropertyException, .beans.PropertyVetoException, .lang.IllegalArgumentException, .lang.WrappedTargetException, .uno.RuntimeException  
setPropertyValues                    ( [in] []string aPropertyNames, [in] []any aValues )  void                            .beans.XMultiPropertySet                      .beans.PropertyVetoException, .lang.IllegalArgumentException, .lang.WrappedTargetException, .uno.RuntimeException  
setPropertyValues                    ( [in] [].beans.PropertyValue aProps )              void                            .beans.XPropertyAccess                        .beans.UnknownPropertyException, .beans.PropertyVetoException, .lang.IllegalArgumentException, .lang.WrappedTargetException  
setValidator                         ( [in] .form.validation.XValidator Validator )      void                            .form.validation.XValidatable                 .util.VetoException  
setValueBinding                      ( [in] .form.binding.XValueBinding aBinding )       void                            .form.binding.XBindableValue                  .form.binding.IncompatibleTypesException  
supportsService                      ( [in] string ServiceName )                         boolean                         .lang.XServiceInfo                            .uno.RuntimeException  
unloaded                             ( [in] .lang.EventObject aEvent )                   void                            .form.XLoadListener                             
unloading                            ( [in] .lang.EventObject aEvent )                   void                            .form.XLoadListener                             
validityConstraintChanged            ( [in] .lang.EventObject Source )                   void                            .form.validation.XValidityConstraintListener    
write                                ( [in] .io.XObjectOutputStream OutStream )          void                            .io.XPersistObject                            .io.IOException  
OpenOffice 4.0 on Win7
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: cannot change ListSource property of table column

Post by Villeroy »

I draw a list box onto an arbitrary document, bind it to an arbitrary record set and bind the load event to Basic MRILib>Module1>mri
When loading the form (when leaving design mode) MRI pops up with an event struct. The event struct has a Source property which reflects the calling object.
Simply bind the load (or some other) event of your object to the mri macro in order to inspect the event which always includes the calling object.
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
User avatar
MTP
Volunteer
Posts: 1620
Joined: Mon Sep 10, 2012 7:31 pm
Location: Midwest USA

Re: cannot change ListSource property of table column

Post by MTP »

I think you can't change the ListSource(0), you have to change the entire ListSource() array, and then you have to refresh the listbox to make it run the new SQL:

Code: Select all

Dim sSource(0) As String
sSource(0) = "SELECT art,id FROM tcg_getraenke WHERE jahr=" +sJahr+ " ORDER BY art"
oSpalteArt.ListSource() = sSource()
oSpalteArt.refresh()
OpenOffice 4.1.1 on Windows 10, HSQLDB 1.8 split database
StephanH2
Posts: 7
Joined: Mon Dec 30, 2013 4:41 pm

Re: cannot change ListSource property of table column

Post by StephanH2 »

Dear Villeroy, dear MTP,

thank you both for your quick and detailed help. It worked as both of you have pointed out by using the required array instead of a string. In the end, I have made this as explicit as possible as you can see below.

Thank you and have a nice weekend
Stephan

Code: Select all

   ' define variables
   Dim oFormMain as variant
   Dim oFormGetraenkeabrechnung as variant
   Dim oSpalteArt as variant
   Dim sJahr as variant
   Dim sSource as variant

   ' get objects
   oFormMain = ThisComponent.DrawPage.Forms.GetByName("MainForm")
   oFormGetraenkeabrechnung = oFormMain.GetByName("frmGetraenkeabrechnung")
   oSpalteArt = oFormGetraenkeabrechnung.getByName("tblGetraenkeabrechnung").getByName("txtGetraenkeArtAuswahl")

   ' define strings and arrays
   sJahr = oFormMain.getByName("numJahr").CurrentValue
   sSource = array("SELECT ""art"",""id"" FROM ""tcg_getraenke"" WHERE ""jahr""=" +sJahr+ " ORDER BY ""art""")

   ' debug using the MRI extension from http://extensions.services.openoffice.org/en/project/mri-uno-object-inspection-tool   
   ' Globalscope.BasicLibraries.LoadLibrary( "MRILib" )
   ' oMRI = CreateUnoService( "mytools.Mri" )
   ' oMRI.inspect( oSpalteArt )
   
   ' set new SQL query according to the desired year and refresh dropdown list  
   oSpalteArt.ListSource() = sSource()
   oSpalteArt.refresh()
OpenOffice 4.0 on Win7
MarkN62
Posts: 1
Joined: Thu Jul 16, 2015 5:54 am

Re: [Solved] Cannot change ListSource property of table colu

Post by MarkN62 »

I had a similar problem where I had Groups and Sub Group Listboxes and I needed the list on the SubGroup to update when I changed the selected value in Group and MTP's reply solved it.
Thanks

Code: Select all

Sub Main
Dim Doc As Object
Dim Form As Object
Dim CtlGroup As Object
Dim CtlSubGroup As Object
Dim StrSQLQuery(0) as String
	Doc = ThisComponent
	Form = Doc.DrawPage.Forms.GetByIndex(0)
	CtlGroup = Form.getByName("lstGroup")
	CtlSubGroup = Form.getByName("lstSubGroup")
	
	'	New Query for Sub Group based on selected Group
	StrSQLQuery(0) = "SELECT SubGroups, ID FROM SubGroups WHERE GroupID = '" & CtlGroup.SelectedItems(0)-1 & "'"
	CtlSubGroup.ListSource() = StrSQLQuery()
	CtlSubGroup.Refresh()
	
End Sub
Open Office 4.1.1 on Windows 8.1
Post Reply