key combinations

S

seeker

I have the following code on a text box:

If KeyCode = vbKeyReturn And Shift = 2 Then
Call newcustomer
KeyCode = 0
End If

and keypreview is set to yes.

When I debug the code and check what is passed keycode = 17 and not 13 and
shif = 2 as it should. What am I doing wrong. Thanks.
 
C

Clifford Bass via AccessMonster.com

Hi,

This may be a case there the debugger messes up the actual contents of
KeyCode because it gains the focus. In which case what you might do is use a
Debug.Print statement to display the actual contents instead of setting a
break point.

Debug.Print "KeyCode = " & KeyCode & " Shift = " & Shift
If KeyCode = vbKeyReturn And Shift = 2 Then
.....

Then you can inspect the Immediate window to see the actual values after
the process has been run.

Or, it could be that it is reporting in KeyCode that you are pressing
the Control key.

Do some trials where all your KeyDown/KeyUp event does is report (with
Debug.Print) the KeyCode and the Shift values to see exactly what is
happening in various situations.

Clifford Bass
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top