me.KeyPreview=True Private Sub Form_KeyPress(KeyAscii As Integer) if keyascii=13 then sendkeys "{TAB}" End Sub
'看一下这段代码吧,放在公共模块中,ok Public Sub Fn(ByRef f As Form, ByRef KeyAscii As Integer) 'Enter键转换Tab键过程,用在表单编辑时 On Error Resume Next If KeyAscii = 13 Then If Not (TypeOf f.ActiveControl Is CommandButton) Then If TypeOf f.ActiveControl Is TextBox Then If Not f.ActiveControl.MultiLine Then KeyAscii = 0 SendKeys "{tab}" End If Else KeyAscii = 0 SendKeys "{tab}" End If End If End If End Sub
Private Sub Form_KeyPress(KeyAscii As Integer)
if keyascii=13 then sendkeys "{TAB}"
End Sub
Public Sub Fn(ByRef f As Form, ByRef KeyAscii As Integer) 'Enter键转换Tab键过程,用在表单编辑时
On Error Resume Next
If KeyAscii = 13 Then
If Not (TypeOf f.ActiveControl Is CommandButton) Then
If TypeOf f.ActiveControl Is TextBox Then
If Not f.ActiveControl.MultiLine Then
KeyAscii = 0
SendKeys "{tab}"
End If
Else
KeyAscii = 0
SendKeys "{tab}"
End If
End If
End If
End Sub