Ask Your Question
0

Base: how to copy contents of one form field to another

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

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 close merge delete

1 Answer

Sort by » oldest newest most voted
0

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

doug gravatar image

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

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
field_dest.commit()

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

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

Stats

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

Seen: 1,351 times

Last updated: Feb 07 '15