Enter key does not work on ListView control

  • Thread starter Thread starter It'sss Johnny
  • Start date Start date
I

It'sss Johnny

Hi all! I'm using a ListView control in an Access XP form. I have setup the
control events so certain code works when a I double-click the item in the
control. So far so good. However, if I use the keyboard instead of the mouse
and press the ENTER key on the selected item, Access moves the focus out of
the Listview control.

I have experimented with the different events for the control, but I'm
unable to catch this ENTER key, since Access traps it first. Thanks in
advance for any suggestions.
 
I know.. I tried all that, but nothing. I want to trigger my code only if
the ENTER key has been pressed within a particular item of the ListView.
Access does not expose the ENTER key on this control; neither allows it to
capture it in any way or form. I cannot just execute the code by using the
Exit event and Lost Focus. I need to verify the user has actually pressed
ENTER on the item.

I have been successful doing it in VB6, but Access does not allow me to trap
this ENTER key. When the ENTER key is pressed Access moves the focus away
from the listview control to the next.
 
It'sss Johnny said:
Hi all! I'm using a ListView control in an Access XP form. I have setup
the control events so certain code works when a I double-click the item in
the control. So far so good. However, if I use the keyboard instead of the
mouse and press the ENTER key on the selected item, Access moves the focus
out of the Listview control.

I have experimented with the different events for the control, but I'm
unable to catch this ENTER key, since Access traps it first. Thanks in
advance for any suggestions.

Try this:

Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long)
As Integer

Put this in the ListView Exit event

If GetAsyncKeyState(vbKeyReturn) = -32767 Then
Cancel = True
Call YourCodeFunctionGoesHere( )
End If
 

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

Back
Top