Use this structure inside the KeyPress event...
If KeyAscii = 13 Then
' The EnterKey was pressed, run your code here
KeyAscii = 0
End If
The KeyAscii = 0 statement has the effect of canceling the KeyPress
(especially needed to stop the beep sound in a single-line TextBox).
Rick
I think that will work perfect. I have been playing with it, but have
run into one problem and maybe you have seen this.
It seems that since the KeyAscii = 0 line of code executed no key
press events work for the form anymore even after restarting the
application.
Do you know how to get the key press event to work again?
Whether it was that command or not there must be a way to get the form
object to turn its keypress events back to enabled?
I like the full control of your approach which will work very fast,
too.[/QUOTE]
KeyAscii = 0 can only affect the one time it is executed... what it does is
substitute the value of 0 for the value passed into the KeyPress press event
(see the KeyAscii argument in the event declaration statement) by the system
for that one event execution only... it cannot be responsible for the
problem you are describing.
Do you by any chance have an Application.EnableEvents=False statement in
your code (which was to be followed by an Application.EnableEvents=True
statement later on)? If so, it sounds like your program exited before you
got a chance to set it back to True (something that should be taken care of
by an On Error statement or logic before an Exit Sub/Function). If this is
the case, just execute Application.EnableEvents=True in the Immediate window
to straighten things back out. If not, you will need to show us your code so
we can see what is going on.
Rick