1

This works to get the value of a field at an event (say a button click):

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

However when I try to fire this on the Form's "After Record Change" event, I get an error: "property or method not found: Model"

How do I get the value of "txtpath" on the "After Record Change" Form event?

Trees4theForest
  • 1,267
  • 2
  • 18
  • 48

1 Answers1

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.

Community
  • 1
  • 1
Jim K
  • 12,824
  • 2
  • 22
  • 51
  • except my data is in fields (text blocks) not in columns... so findColumn() appears not to work. How do I find something simple like what methods does the form object now allow? My field is named txtpath which displays data path, it has the label (aka lblpath). Thanks! – Trees4theForest Jul 11 '16 at 22:06
  • Moved discussion to http://chat.stackoverflow.com/rooms/117030/room-for-jim-k-and-trees4theforest-libreoffice-base-get-form-field – Jim K Jul 11 '16 at 23:24