Ask Your Question
0

Get value from form in Base

asked 2018-08-29 17:03:27 +0200

LO EJ gravatar image

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.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2018-08-29 18:06:15 +0200

Ratslinger gravatar image

updated 2018-08-30 16:29:17 +0200

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

edit flag offensive delete link more

Comments

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.

LO EJ gravatar imageLO EJ ( 2018-08-30 12:36:33 +0200 )edit

Please see edit in answer.

Ratslinger gravatar imageRatslinger ( 2018-08-31 07:08:53 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2018-08-29 17:03:27 +0200

Seen: 453 times

Last updated: Aug 30 '18