Get value from form in Base

This is my first time using Base. Been trying a million things that I found online. No stranger to database coding, just can’t get it to work with Base.

What I have is a very simple form with a few fields on it and a button. When the button is pressed, I need to get the value of the fields on the form. Nothing I have found works.

This seem to be the most comprehensive example I found:

Sub Main

DIM Doc as object

DIM Drawpage as object

DIM Form as object

DIM DateField as object

DIM DateStr as string

DIM PersonField as object

DIM PersonStr as string

Doc = thisComponent

Drawpage = Doc.drawpage

Form = Drawpage.forms.getByName(“Form”)

DateField = Form.getByName(“Date”).getDate()

DateStr = Form.GetByName(“Date”).getCurrentVal()

msgbox(“Date = >” + DateStr + “<”)

PersonField = Form.getByName(“Person”)

PersonStr = PersonField.currentvalue

msgbox(“Person = >” + PersonField.getText() + “<”)

End Sub

No matter what I try to get the value, I get a runtime error that it is unknown. I have tried:

getDate()
getValue()
getValue
getCurrentValue()
getCurrnetValue
Text
getText()

I have seen all of these in various postings. None of them work. If I can get the date to work, I’m sure I can get the rest to work.

Sorry, this is my first post, so not sure if I’m formatting correctly.

Hello,

Only reason I can see you trying this is simply to see what can be done. Macros in LO Base is NOT database coding. It is comprised of using Basic (or another language such as Python) and the Uno API. A lot to take in as someone new to Base.

For an extensive look at LO macros, see Open Office Macros Explained by Andrew Pitonyak - OOME PDF here.

Edit 2018-0830

Have re-done the code for simplicity & clarity:

Sub Main
    DIM Form as Object
    DIM DateStr as Object
    DIM PersonField as object
    Form = ThisComponent.Drawpage.forms.getByName("Form")
    DateStr = Form.GetByName("Date").getCurrentValue()
    msgbox "Date = >" & DateStr.Day & DateStr.Month & DateStr.Year & "<"
    PersonField = Form.getByName("Person")
    msgbox "Person = >" & PersonField.Text & "<"
End Sub

As it is not clear as to how your form and controls are established, a sample is attached. The form is simple. The date control comes from the table. The text box is not connected to anything. It is used to enter text so it can be retrieved & displayed in a Message Box. The push button will display the date from the date control & the text from the text box.

Sample ---- DisplayTextDate.odb

Thanks, but that still doesn’t work. Get this:

BASIC runtime error.
Property or method not found: getCurrentValue

Been getting that for 3 days now.

Just trying to put a couple boxes in a form that will be used as filters. The query will be a little complex, so doing it in a macro. But, it simply cannot perform the basic action of being able to get the value out of the form field.

Deciding that this product is basically unusable.

Please see edit in answer.