How to catch keyreturn in Listview (1 Viewer)

atzdgreat

New member
Local time
Today, 12:47
Joined
Sep 5, 2019
Messages
23
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

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 03:47
Joined
May 7, 2009
Messages
19,169
maybe use Keypress event.
 

atzdgreat

New member
Local time
Today, 12:47
Joined
Sep 5, 2019
Messages
23
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

MVP / VIP
Local time
Today, 19:47
Joined
Jan 14, 2017
Messages
18,186
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, 12:47
Joined
Sep 5, 2019
Messages
23
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

MVP / VIP
Local time
Today, 19:47
Joined
Jan 14, 2017
Messages
18,186
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, 12:47
Joined
Sep 5, 2019
Messages
23
yes since i am at is with listview than listbox.. but do you think windows 32 it will?:(:(:(
 

isladogs

MVP / VIP
Local time
Today, 19:47
Joined
Jan 14, 2017
Messages
18,186
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, 15:47
Joined
May 21, 2018
Messages
8,463
I tried it in listview and got the same results. Return not captured.
 

Users who are viewing this thread

Top Bottom