Budi Rianto wrote:
Hi Andrew and All,

I've follow your instruction and ..well, it's everything you've said.
I removed data field property value and List Entries property's automatically 
enabled. Multiple selection will work but I can't save the values since it 
doesn't know where to put them, which is exactly what I want to do.

Thanks,
Budi

  
  
Budi,

Here is an example of kind of hard coded way to set the value to
a varchar field.

Just like what I am doing for filter settings you would do the same,
create a procedure or function and assign it the Item Status Changed,
something like this.

'--------- copy from here----------
' a character to separate the
' individual values in our
'aggregate field
const separator = ";"

' by adding the parameter oEv
' to our procedure
' we have access to the event
' object, and thru it to
' the listbox directly
Sub onLbxStatusChange( oEv as Object)

' a tempory string for the aggregate value
dim newValue as string

' just a loop controler
dim cntr as integer

' the selected items property
' of the listbox is an array of
' strings - by using a variant
' type for our local variable
' we don't have to worry about
' dimensions ahead of time
' we are also covered in case
' we should ever get a null value
dim selItems as variant

selItems = oEv.Source.SelectedItems

' not sure we could ever have the case of
' selItems = null but doesn't hurt to check
' I suppose
if not isEmpty(selItems) then
  for cntr = LBound(selItems) to UBound(selItems)
    if newValue <> "" then
      newValue = newValue & Separator
      end if
    newValue = newValue & Selitems(cntr)
    next cntr
else
  newValue = ""
  end if

' lets look at the value we would put to the database
print newValue

' here you would put newValue
' to the correct field or column
' for example I had a field on
' my form named txtADD2 of type
' varchar and belonging to the same dataform   
' object as the listbox so to reference
' the actual column on the rowset I could
' do something like this
' oEv.Source.Model.Parent.getByName( "txtADD2" ).BoundField.UpdateString( newValue )
'

End Sub

'------------ copy to here ----------------

Jees, looks like a lot doesn;t it. It really isn't, lots of comments. Besides this would be a
good candidate for a macro library, where you would just pass in the list box and the
name of the control to put the value to. hmm..maybe someone should write that. :-)

As for updating the listbox with values as the records change on the form, it is
pretty much just the reverse of this process. We grab the value, break it apart
at the seperator character and then loop thru the array of strings to select the
items that match in the  listbox. The question would be which event to hook
for this. Not sure if the dataform's "After Record Change" or something on
the bound control for the varchar column is the best place. I will see what I can
come up with. If we could make a generalized function for that also, then it just
might turn this into a trival exercise of just adding the library code into your application.

If you want to get a good start on the Basic language there really are three things you
have to grab the StarOffice 7 or 8 Basic Programming Guide from the Sun website,
the macro guide from Andrew Pitonyak at http://www.pitonyak.org
and the Xray tool By...jees forgot his name, got it..Bernard Marcelly, and you can get it
http://ooomacros.org/dev.php#101416

Why OO.o doesn't just include that last item in the distribution is beyond me, not having
it and trying to learn the ins and outs of macros is like going fishing without a hook!

 HTH

Andrew

 

Reply via email to