ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Run command when hitting ENTER on list box item (https://www.excelbanter.com/excel-programming/280664-run-command-when-hitting-enter-list-box-item.html)

Mr. Smith

Run command when hitting ENTER on list box item
 
Hi.

I have a listbox with several items. If the users double click on an item, a
detail info form are retrieved for the current item. I want the same thing
to happen when the user click ENTER on a highlighted item in a list box

something like this:

Sub frm_mainList_KeyDown()
If application.onkey = {ENTER} THEN
frm_details.show
End if
End sub


Please clean up my code, somone.

Mr. Smith




Dave Peterson[_3_]

Run command when hitting ENTER on list box item
 
Couldn't you just use either/both of these:

Option Explicit
Private Sub ListBox1_Click()
MsgBox "Click"
End Sub
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
MsgBox "dclick"
End Sub



"Mr. Smith" wrote:

Hi.

I have a listbox with several items. If the users double click on an item, a
detail info form are retrieved for the current item. I want the same thing
to happen when the user click ENTER on a highlighted item in a list box

something like this:

Sub frm_mainList_KeyDown()
If application.onkey = {ENTER} THEN
frm_details.show
End if
End sub

Please clean up my code, somone.

Mr. Smith


--

Dave Peterson



All times are GMT +1. The time now is 08:51 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com