Hi.
Trying to set form control along the lines of
How to update field in table with datediff result
Why I’m getting Error in
Dep = Evt.Source.Model
?
Event = After update DEP
If I set Dep = Evt.Source difference in days is inserted in the control, but table does not update (of course I think).
Thanks in advance!
Option Explicit
Sub SetStay(Evt) ' source = DEP field
Dim Grid As Object, Arr As Object, Dep As Object, Days As Object
Dim dt_arr As New com.sun.star.util.Date
Dim dt_dep As New com.sun.star.util.Date
Dim d As Integer
GlobalScope.BasicLibraries.LoadLibrary("MRILib")
On Error GoTo Erro
REM SET VARIABLES FOR THE CONTROLS:
Dep = Evt.Source.Model
Grid = Dep.Parent
Arr = Grid.getByName("ARR")
dt_arr = Arr.Date
dt_dep = Dep.Date
Days = Grid.getByName("DAYS")
REM COMPUTE STAY DAYS
d = DateDiff("d", CDateFromUnoDate(dt_arr), CDateFromUnoDate(dt_dep))
Days.Value = d
Exit Sub
Erro: MsgBox "ERRO " & Err & Chr(10) & "na linha " & Erl
End Sub

but if I just print d

