Solved

Hotkey - SPACE BAR

Posted on 2002-04-25
4
764 Views
Last Modified: 2012-06-27
I use KeyPreview = True for form

Then have:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeySpace Then
 etc etc

Problem - if i run the program it performs the keydown event ok but also any command button that has the focus at the time - no good

How to simply get the SPACE BAR to perform something on its own ?
0
Comment
Question by:clapper100497
  • 2
  • 2
4 Comments
 
LVL 6

Accepted Solution

by:
DrDelphi earned 100 total points
ID: 6970326
Try this:

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 32 Then
   MsgBox "Space key pressed"
   KeyCode = 0
End If



Good luck!!
0
 

Author Comment

by:clapper100497
ID: 6970333
KeyCode = 0 did the trick !
Well done and thanks !!!!
0
 

Author Comment

by:clapper100497
ID: 6970335
Thanks for such a simple solution
Appreciated !!!
0
 
LVL 6

Expert Comment

by:DrDelphi
ID: 6970342
Cheers.

0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

777 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