Press enter in textbox and execute button function in VBA

前端 未结 5 880
春和景丽
春和景丽 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:54

    KeyPress rather than KeyDown works for me, and calling the _Click sub avoids sending triggers that may fire other events.

    Private Sub txtboxPassword_KeyPress(KeyAscii As Integer)
        If KeyAscii = 13 Then
             Call btnLogin_Click
        End If
    End Sub
    

提交回复
热议问题