Why is my .setfocus ignored?

前端 未结 6 2096
一生所求
一生所求 2020-12-06 11:46

I have an Access form with a textbox that is meant to allow for repeatedly typing a number, hitting enter, and letting a script do stuff. For speed, the field should keep t

6条回答
  •  执笔经年
    2020-12-06 12:39

    An easy solution that works in Excel is to set the KeyCode to 0. If DoStuff steals the focus then you should also set the focus back:

    Private Sub MyFld_KeyDown(KeyCode As Integer, Shift As Integer)  
         If KeyCode = vbKeyReturn Then  
             DoStuff 
             KeyCode = 0
             Me.MyFld.SetFocus  
         End If
    End Sub
    

提交回复
热议问题