Press enter in textbox and execute button function in VBA

前端 未结 5 893
春和景丽
春和景丽 2020-12-11 06:23

I have a login form to my database done in Access 2010 and using VBA code. I want to be able to press Enter on txtboxPassword and automatically execu

5条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-11 06:58

    Cant reproduce exactly your problem, but some time ago I had somewhat similar issue and solved it by adding:

    Private Sub txtboxPassword_KeyDown(KeyCode As Integer, Shift As Integer)
      If KeyCode = 13 Then
         btnLogin_Click
         KeyCode.Value = 0
      End If
    End Sub
    

提交回复
热议问题