LibreOffice Base Basic在加载时获取表单字段值

时间:2016-07-11 15:19:20

标签: forms scripting libreoffice

这可以在事件中获取字段的值(比如按一下按钮):

Sub runatevent(Event as Object)
    dim form as Object
    dim cntrl
    form = Event.Source.Model.Parent
    cntrl = form.getByName("txtpath").currentvalue
    print(cntrl)
End Sub

但是当我尝试在Form的“After Record Change”事件中触发它时,我收到一个错误:“找不到属性或方法:Model”

如何在“After Record Change”表单事件中获取“txtpath”的值?

1 个答案:

答案 0 :(得分:2)

To figure this out, I used XrayTool on the Event object. This is what worked:

form = Event.Source

As in my answer to your other question, I suggest reading the value from the result set:

nameCol = form.findColumn("PATH")
print(form.getString(nameCol))

The idea is that the form is based on a result set, so you can just read from the result set rather than getting a control from the form and then checking the value of the control. Just a little more elegant in my opinion.