Go to field

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
macbeth
Posts: 61
Joined: Mon Nov 09, 2009 6:47 pm

Go to field

Post by macbeth »

Hi, this must be simple but I can't find any documentation to do it. I want when I click on button on a form to open new record and go to a specific field on the form. Can I edit this to do that ( the field is called "Pattern Field Date":

Code: Select all

sub new_record
rem ----------------------------------------------------------------------
rem define variables
dim document   as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:NewRecord", "", 0, Array())


end sub
OpenOffice 3.2 on Win Vista
macbeth
Posts: 61
Joined: Mon Nov 09, 2009 6:47 pm

Re: Go to field

Post by macbeth »

Any help on this, please?
OpenOffice 3.2 on Win Vista
rudolfo
Volunteer
Posts: 1488
Joined: Wed Mar 19, 2008 11:34 am
Location: Germany

Re: Go to field

Post by rudolfo »

What kind of form is this? Is it bound to a database object (table, view or query)?
As you are talking of records I assume this is the case. If you create a button in the design mode you right click on it and choose "Control Properties". On the event tab page creating a new record is one of the suggested actions.
Search the Base forum for button, new record or something like that.
The macro recorder with its dispatcher calls won't help you with this. And in general one of the recommendations when working with Base is to avoid macros as long as possible.
OpenOffice 3.1.1 (2.4.3 until October 2009) and LibreOffice 3.3.2 on Windows 2000, AOO 3.4.1 on Windows 7
There are several macro languages in OOo, but none of them is called Visual Basic or VB(A)! Please call it OOo Basic, Star Basic or simply Basic.
macbeth
Posts: 61
Joined: Mon Nov 09, 2009 6:47 pm

Re: Go to field

Post by macbeth »

Thank you for the reply! I already have the button on the form called"new" and when I click it it goes to a new blank record. I would then like it to put the cursor in the first field "date" so I can just click on "new" and then start entering data. Yes the form is bound to a table.
OpenOffice 3.2 on Win Vista
RPG
Volunteer
Posts: 2250
Joined: Tue Apr 14, 2009 7:15 pm
Location: Netherlands

Re: Go to field

Post by RPG »

Hello

Learn first what you can do without macros and it seems to me it can be done whithout a macro.

Study all the properties of a button. One of then is getting focus on click.
For the form you can organize the tab-order for a simple form you can manage this maybe complete without any macro.

Romke
LibreOffice 7.1.4.2 on openSUSE Leap 15.2
macbeth
Posts: 61
Joined: Mon Nov 09, 2009 6:47 pm

Re: Go to field

Post by macbeth »

I thought this would be easy, apparently not as I can't find any info how to. I've got it working so that after I click on the "new" button I just hit the tab key and it goes to the first field. It would have been much better to do this just by clicking the "new" button.
OpenOffice 3.2 on Win Vista
RPG
Volunteer
Posts: 2250
Joined: Tue Apr 14, 2009 7:15 pm
Location: Netherlands

Re: Go to field

Post by RPG »

Hello

I think your button gets focus and I think it must not get focus.

Romke
LibreOffice 7.1.4.2 on openSUSE Leap 15.2
macbeth
Posts: 61
Joined: Mon Nov 09, 2009 6:47 pm

Re: Go to field

Post by macbeth »

Yes, you're right, but if I select not to get focus how do I get the field I do want to get the focus?
OpenOffice 3.2 on Win Vista
RPG
Volunteer
Posts: 2250
Joined: Tue Apr 14, 2009 7:15 pm
Location: Netherlands

Re: Go to field

Post by RPG »

Hello

There is a button on the toolbar for forms what organize the taborder maybe this can help you. When you want work with forms then you have to study all this kinds of details.

I cannot see your form. So I cannot say that you can do it without macros. But I think you must first learn what you can do with forms without macros. Maybe you have to redesign your form in a way that it can do what you want. Maybe you have to use not OOo but an other tool for making forms but I have no idea.

Romke
LibreOffice 7.1.4.2 on openSUSE Leap 15.2
Post Reply