Ask Your Question
0

base macro to restore focus to a form field

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

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
0

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

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'
    CtlView.setFocus()
edit flag offensive delete link more

Comments

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 +0200 )edit

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

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

thanks, that works!

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

Question Tools

1 follower

Stats

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

Seen: 556 times

Last updated: Jul 20 '16