Ask Your Question

Base: how to copy contents of one form field to another [closed]

asked 2013-06-12 01:23:04 +0100

mow9902 gravatar image

I have a very simple form - let's say two text input boxes only.

I would like a macro to copy whatever content is entered into box 1 and enter it into box 2. Can this be done?

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp
close date 2020-08-15 16:00:26.304400

1 Answer

Sort by » oldest newest most voted

answered 2015-02-07 05:08:20 +0100

doug gravatar image

updated 2015-02-07 12:59:10 +0100

Big picture, this is not a great idea. Data should be stored only once. That said, the code in LO Basic you are looking for is as follows for text box controls. Every kind of control has a different method, text boxes use method text while numeric boxes use value; use .dbg_methods and .dbg_properties to find right method:

root_doc = ThisComponent

form_container = root_doc.Drawpage.Forms
main_form = form_container.MainForm

field_src = main_form.getByName("TextBox1")
field_dest = main_form.getByName("TextBox2")

field_dest.text = field_src.text

Have this macro be triggered from push button, loss of focus on source, something like that.

edit flag offensive delete link more

Question Tools


Asked: 2013-06-12 01:23:04 +0100

Seen: 1,631 times

Last updated: Feb 07 '15