How to assign number format to merge field with macro?

Hello Everybody

How do you set the NumberFormat of a Mail Merge Field in a Writer document with a macro?
What I’m doing is: opening a .odt file and doing some sort of ‘Data to Fields’ procedure with a macro depending on the ID of the database record.
The problem is: when setting the content coming out of the Database table in the mail merge fields, the format of this new content won’t change to the format assigned to the field. Resetting the format of the field does not change how the content looks :frowning:

I’ve got this:

oEnum = oDoc.getTextFields.createEnumeration 'Enumerate text fields.
    While oEnum.hasMoreElements
    thisField = oEnum.nextElement
    ilFormatDalField = thisField.NumberFormat

    'Xray thisField
    If thisField.SupportsService("com.sun.star.text.TextField.Database") then 'Its a DB field.
      TFM = thisField.getTextFieldMaster 'Get text field master.
      If TFM.DataBaseName = DBname then 'The field is from the current database.
        fieldName = TFM.DataColumnName 'Get the field name.
        If DBrow.Columns.hasByName(fieldName) then 'Current DB row has this field name.
          'Xray DBrow.Columns.getByName(fieldName)
          s$ = DBrow.Columns.getByName(fieldName).getString(1) 'Get desired presentation string.
          'If IsDate(s$) then
          'print "ei in datum"
          'EndIf
          'If IsNumeric(s$) then
          'print "ei in Numeric"
          'EndIf
          'print s$
          thisField.CurrentPresentation = s$ 'Set the presentation.
          thisField.NumberFormat = IlFormatDalField
          thisField.update
          'Xray thisField   
         Else ExtraFN = ExtraFN + 1 'Foreign field name count.
        EndIf
       Else ExtraDB = ExtraDB + 1 'Foreign database count.
      Endif
    EndIf
    Wend
    oDoc.Modified = true

The NumberFormat is being set, but is somehow not applied to the content of the Mail Merge Field (SwXTextField). In other words: the number/date/what ever just stays the same (i.e. the string that is returned form the DB).

what am I doing wrong?

as you probably see, I’m just hacking my way through the whole Macro-business Wink

thank you very much for your time!

LibreOffice 5.0.1.2, Mac OS 10.8.5