Ask Your Question

base macro to restore focus to a form field

asked 2016-07-20 15:52:09 +0100

jvglynnjr gravatar image

I have a Base form that runs a macro when the value is entered, but then the focus shifts to the next tab stop. How can I make the focus return to the control again?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2016-07-20 16:46:38 +0100

Ratslinger gravatar image
'Get Form'
    oForm = ThisComponent.Drawpage.Forms.getByName("MainForm")
'Get Field'
    oField = oForm.getByName("txtMyControl")
'Get field VIEW'
    CtlView = ThisComponent.getCurrentController().getControl(oField)
'Set Focus'
edit flag offensive delete link more


I tried adding this code to the end of my macro, got "BASIC run time error. Variable not defined."

oForm = ThisComponent.Drawpage.Forms.getByName("Form1")

jvglynnjr gravatar imagejvglynnjr ( 2016-07-20 21:06:25 +0100 )edit

If you have Option Explicit set you must Dim the variables.

Ratslinger gravatar imageRatslinger ( 2016-07-20 21:42:03 +0100 )edit

thanks, that works!

jvglynnjr gravatar imagejvglynnjr ( 2016-07-22 03:04:12 +0100 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2016-07-20 15:52:09 +0100

Seen: 1,076 times

Last updated: Jul 20 '16