Solved

Question About KeyUp and ListBoxes

Posted on 2009-04-13
8
271 Views
Last Modified: 2013-11-28
I have a list box that is being monitored for key events.  When I tab to the list box I can use the arrow keys to select a record.  With a record selected, I want to trigger an action when the Return key is pushed.  The event does not fire on the first push; it fires on the second.  Why is this?

Mike

0
Comment
Question by:shacho
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
8 Comments
 
LVL 75

Assisted Solution

by:DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 300 total points
ID: 24134513
why not use KeyDown ?

mx
0
 
LVL 75
ID: 24134543
Why are you using the Return key in the List box?
0
 

Author Comment

by:shacho
ID: 24134907
>why not use KeyDown ?
Tried KeyDown.  It works.  But why should KeyDown work on the first Enter and not KeyUp?
I chose KeyUp because I figured it was good policy to run code after key events were concluded
and KeyUp should logically run after KeyDown.

>Why are you using the Return key in the List box?
The listbox is a search results list.  I want people who prefer to use the keyboard over the mouse
to be able to launch the viewer for the selected record with the Return key in case they don't want
to double-click.

Mike
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 300 total points
ID: 24134935
Not sure why Key Down works over Key Up ... but it's still a valid event ... and for most applications I can think of, that is what I use. Actually on my test for, Key Up works on the first time.  However ... if nothing is selected and I tab into the list box ... and hit down arrow ... it selects the first item ... and so on.  BUT ... if I hit Enter at any time ... it goes to the next control in the tab order!

mx
0
 
LVL 65

Assisted Solution

by:rockiroads
rockiroads earned 200 total points
ID: 24135272
the difference I thought was

keydown - user presses a key
keyup - user releases a key

so explains why keydown gets called first, as you have concluded yourself.

But it doesnt need two pushes, unless maybe you have caught it elsewhere first?
Have you a form capture event?

I for one prefer the use of keypress but thats not going to answer your question now is it, lol.
0
 
LVL 75

Assisted Solution

by:DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 300 total points
ID: 24135282
However ... Keypress does not catch all codes ...

Yes ... sure, that is the difference between the two ...

mx
0
 
LVL 65

Assisted Solution

by:rockiroads
rockiroads earned 200 total points
ID: 24135318
no, though it does catch return key but if you want to catch the use of shift, ctrl etc then you have to use the other key events.
0
 

Author Comment

by:shacho
ID: 24165021
Well, I'm gonna chalk it up to plain old bugginess because I think KeyUp should work.  Thanks for your suggestions.

Cheers,

Mike
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question