Hello.
I'd like to create a button on my form that sets the focus to a particular field, and then opens up a new record for data entry.
Which control should I use for this? And are there pre-designed macros that I can plug into the button for this?
I tried using the Push Button control, but couldn't figure out what to do from there. Is the Push Button control the right one to use?
Thank you! Jd
How Do I Create a Form Button to Add a New Record?
Re: How Do I Create a Form Button to Add a New Record?
Draw a button and set it's "Action" property to "New record". I don't know about the focus.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: How Do I Create a Form Button to Add a New Record?
Jd,
Villeroy's suggestion sets the focus to the first entry control here.
If you like to set the focus to another control, use the following code [copy it to a module in "My Macros"], adjust the control name [getByName statement], and assign to the "When initiating" event of your pushbutton:
Works here with OOo 2.4.0rc6-de 2008-03-14
Villeroy's suggestion sets the focus to the first entry control here.
If you like to set the focus to another control, use the following code [copy it to a module in "My Macros"], adjust the control name [getByName statement], and assign to the "When initiating" event of your pushbutton:
Code: Select all
Sub base_newRecordAndFocus
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:NewRecord", "", 0, Array())
oDoc = ThisComponent
oDocView = oDoc.getCurrentController()
oForm = oDoc.drawpage.forms(0)
oFeld = oForm.getByName("fmtnumwert")
oDocView.getControl(oFeld).setFocus()
End Sub
Re: How Do I Create a Form Button to Add a New Record?
I've change my mind about something.
I want a separate control button JUST to set the focus to a specific field.
I've created separate push buttons for adding and deleting a record.
Can I create a separate control button that sets the focus to a specific field, without any code? Or do I need code to do that?
I didn't see a SET FOCUS option under Action.
How can I revise your code to do that, if code is, in fact, required? And what part of the code will I have to revise for my form, so it sets the focus to the field of my choice?
Thank you. Jd
I want a separate control button JUST to set the focus to a specific field.
I've created separate push buttons for adding and deleting a record.
Can I create a separate control button that sets the focus to a specific field, without any code? Or do I need code to do that?
I didn't see a SET FOCUS option under Action.
How can I revise your code to do that, if code is, in fact, required? And what part of the code will I have to revise for my form, so it sets the focus to the field of my choice?
Thank you. Jd
Re: How Do I Create a Form Button to Add a New Record?
I don't know how to set focus w/o using code (there is no setFocusHere action, as you found out).
just take the last five statements - change the name in getByName statement - to set the focus to YOUR control.
just take the last five statements - change the name in getByName statement - to set the focus to YOUR control.
Re: How Do I Create a Form Button to Add a New Record?
If I remember correctly, each form control has a peer (a sub-window in the component window) with interface c.s.s.awt.XWindow and method setFocus().
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: How Do I Create a Form Button to Add a New Record?
It's not a real big deal...thanks for helping out. I was just curious about it.
-
- Posts: 1
- Joined: Sun Jul 19, 2009 2:32 pm
Re: How Do I Create a Form Button to Add a New Record?
If you create a button to add new record ,set the tab order of the control you wish to have focus to be after the button.
OOo 2.4.X on Ubuntu 8.x + XP