How to catch keyreturn in Listview (1 Viewer)

atzdgreat

New member
Local time
Today, 11:12
Joined
Sep 5, 2019
Messages
8
hi may i know why it wont catch the enter key in listview control in access.

Code:
Private Sub lvCMAList_KeyDown(KeyCode As Integer, ByVal Shift As Integer)
    Dim DirFile As String
    Dim NewCtr As Integer
    Dim BOk As Boolean
    Dim msg
    Dim LV  As MSComctlLib.ListView
    Set LV = Me.lvCMAList.Object
    
    If KeyCode = vbKeyDown Then
       'THIS WORKS
    ElseIf KeyCode = vbKeyUp Then
      'THIS WORKS
    ElseIf KeyCode = vbKeyReturn Then
      'THIS DOESNT WORK
    End If
    
    Set LV = Nothing
End Sub
 

arnelgp

error reading drive A:
Local time
Tomorrow, 02:12
Joined
May 7, 2009
Messages
9,872
maybe use Keypress event.
 

atzdgreat

New member
Local time
Today, 11:12
Joined
Sep 5, 2019
Messages
8
hi sir arnel, thank you for your reply. i tried keypress event but still no luck. i dont know why only vbkeydown=vbkeyreturn or keyascii=13 cannot be catch. the rest keys are fine. i tried changing the option/Client Settings/ Move after enter to Dont move or next field as well
 

isladogs

CID
Local time
Today, 19:12
Joined
Jan 14, 2017
Messages
13,602
Just tested and this worked perfectly for me for all the key strokes I tested

Code:
Private Sub Text0_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then 'vbKeyReturn
   MsgBox "Return key pressed"
Else
   MsgBox "The '" & Chr(KeyAscii) & "' key was pressed"
End If
   
End Sub
However its a textbox not a listview….
Can you try it in your list view control
 
Last edited:

atzdgreat

New member
Local time
Today, 11:12
Joined
Sep 5, 2019
Messages
8
yes i tested it in textbox and it works fine. but in listview it doesnt. hmmm maybe because listview is not part of access? unlike in excel? since we need to declare the listview first like...

Code:
Dim LV  As MSComctlLib.ListView
im not so sure with this.
 

isladogs

CID
Local time
Today, 19:12
Joined
Jan 14, 2017
Messages
13,602
A listview isn't a standard Access control and is I believe not supported in 64-bit Access. I haven't used it for many years.
Is there a particular reason why you need to use that control?
 

atzdgreat

New member
Local time
Today, 11:12
Joined
Sep 5, 2019
Messages
8
yes since i am at is with listview than listbox.. but do you think windows 32 it will?:(:(:(
 

isladogs

CID
Local time
Today, 19:12
Joined
Jan 14, 2017
Messages
13,602
Sorry but I don't understand what you are asking.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 14:12
Joined
May 21, 2018
Messages
3,247
I tried it in listview and got the same results. Return not captured.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top Bottom