Text Box Question (simple Im sure)

I have created a simple data entry form. Currently the user uses the TAB button to move to the next control. However, I would like to also allow the user to just hit enter to move to the next control.

So, I tried this:

'*******************************************
Private Sub txtCompanyName_KeyUp(KeyCode As Integer, Shift As Integer)

If KeyCode = 13 Then
TxtAddress.SetFocus
Exit Sub
End If

End Sub
'*******************************************

It works. However I always get an anoying beep when I hit enter. I believe this to be because the 'MultiLine' property of the TextBox is set to false.

Is there a better way of doing this?
Can I get rid of the beep?

Thanks,
Tony
[809 byte] By [mytonytiger] at [2007-11-15 16:17:04]
# 1 Re: Text Box Question (simple Im sure)
Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyReturn Then
SendKeys "{TAB}"
KeyAscii = 0
End If
End Sub

Private Sub Form_Load()
Me.KeyPreview = True
End Sub

If you do it this way, you do not need to use code in eack textbox keypress event. You may still need to set the multiline property of the textbox if it is runs under win95.

David Paulson
d.paulson at 2007-11-10 0:59:01 >
# 2 Re: Text Box Question (simple Im sure)
This is the way I originally WANTED to do it.
I just didn't know about "SendKeys". Thanks alot! Just what I needed.
mytonytiger at 2007-11-10 1:00:04 >