Go to field

The Application Programming Interface and the OASIS Open Document Format

Go to field

Postby macbeth » Wed Oct 27, 2010 4:23 pm

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   Expand viewCollapse view
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

Postby macbeth » Mon May 09, 2011 5:12 pm

Any help on this, please?
OpenOffice 3.2 on Win Vista
macbeth
 
Posts: 61
Joined: Mon Nov 09, 2009 6:47 pm

Re: Go to field

Postby rudolfo » Tue May 10, 2011 2:54 am

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.
rudolfo
Volunteer
 
Posts: 1488
Joined: Wed Mar 19, 2008 11:34 am
Location: Germany

Re: Go to field

Postby macbeth » Tue May 10, 2011 5:31 pm

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
macbeth
 
Posts: 61
Joined: Mon Nov 09, 2009 6:47 pm

Re: Go to field

Postby RPG » Tue May 10, 2011 6:24 pm

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 6.3.3.2 on openSUSE Leap 15
RPG
Volunteer
 
Posts: 2192
Joined: Tue Apr 14, 2009 7:15 pm
Location: Netherlands

Re: Go to field

Postby macbeth » Thu May 12, 2011 5:23 pm

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
macbeth
 
Posts: 61
Joined: Mon Nov 09, 2009 6:47 pm

Re: Go to field

Postby RPG » Thu May 12, 2011 7:20 pm

Hello

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

Romke
LibreOffice 6.3.3.2 on openSUSE Leap 15
RPG
Volunteer
 
Posts: 2192
Joined: Tue Apr 14, 2009 7:15 pm
Location: Netherlands

Re: Go to field

Postby macbeth » Thu May 12, 2011 10:49 pm

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
macbeth
 
Posts: 61
Joined: Mon Nov 09, 2009 6:47 pm

Re: Go to field

Postby RPG » Thu May 12, 2011 11:12 pm

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 6.3.3.2 on openSUSE Leap 15
RPG
Volunteer
 
Posts: 2192
Joined: Tue Apr 14, 2009 7:15 pm
Location: Netherlands


Return to UNO API and ODF

Who is online

Users browsing this forum: No registered users and 5 guests