PC Review


Reply
Thread Tools Rate Thread

Create Hotkey to Open Form?

 
 
croy
Guest
Posts: n/a
 
      5th Nov 2007
How do I create a hotkey to open a form?

In one control on a form, I'd like the "+" key on the
numerical keypad to open a certain form, or cause the
OnClick event to run.

MS Access 2002.

--
croy
 
Reply With Quote
 
 
 
 
John Smith
Guest
Posts: n/a
 
      6th Nov 2007
Use the KeyPress event of the control:

Private Sub SomeControl_KeyPress(KeyAscii As Integer)
If KeyAscii = 43 Then
DoCmd.OpenForm "Some Form"
KeyAscii = 0 ' Stop the + from going to the control
End If
End Sub

Plus whatever other code you need.

HTH
John
##################################
Don't Print - Save trees

croy wrote:
> How do I create a hotkey to open a form?
>
> In one control on a form, I'd like the "+" key on the
> numerical keypad to open a certain form, or cause the
> OnClick event to run.
>
> MS Access 2002.
>

 
Reply With Quote
 
croy
Guest
Posts: n/a
 
      6th Nov 2007
On Tue, 06 Nov 2007 13:00:01 +0000, John Smith
<johnDOTsmithATbromleyhospitalsDOTnhsDOTuk> wrote:

>Use the KeyPress event of the control:
>
>Private Sub SomeControl_KeyPress(KeyAscii As Integer)
> If KeyAscii = 43 Then
> DoCmd.OpenForm "Some Form"
> KeyAscii = 0 ' Stop the + from going to the control
> End If
>End Sub
>
>Plus whatever other code you need.



Thanks John. That's a huge help, especially the comments in
the code.

If there is already form-opening code for the OnClick event
for this control, is it better to call the OnClick event, or
use separate code, like above (assuming that it's even
possible to call another event's code)?

--
croy
 
Reply With Quote
 
John Smith
Guest
Posts: n/a
 
      7th Nov 2007
Personally I try to avoid having more than one piece of code doing the same
thing so I would call the existing code. If you don't it tends to trip you up
later when you change one call but forget about the other one!

Just call it by name, something like:

ControlName_Click

John
##################################
Don't Print - Save trees

croy wrote:
> On Tue, 06 Nov 2007 13:00:01 +0000, John Smith
> <johnDOTsmithATbromleyhospitalsDOTnhsDOTuk> wrote:
>
>> Use the KeyPress event of the control:
>>
>> Private Sub SomeControl_KeyPress(KeyAscii As Integer)
>> If KeyAscii = 43 Then
>> DoCmd.OpenForm "Some Form"
>> KeyAscii = 0 ' Stop the + from going to the control
>> End If
>> End Sub
>>
>> Plus whatever other code you need.

>
>
> Thanks John. That's a huge help, especially the comments in
> the code.
>
> If there is already form-opening code for the OnClick event
> for this control, is it better to call the OnClick event, or
> use separate code, like above (assuming that it's even
> possible to call another event's code)?

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I create a hotkey for my sidebar? =?Utf-8?B?SEFMVVpJTkFHRU4=?= Windows Vista General Discussion 3 22nd Oct 2006 10:55 PM
Can I create a hotkey to mute/unmute in XP? Franklin Windows XP General 3 28th Aug 2004 04:03 AM
Can I create a hotkey to mute/unmute in XP? Franklin Freeware 3 28th Aug 2004 04:03 AM
Can I create a hotkey to mute/unmute in XP? Franklin Windows XP Hardware 3 28th Aug 2004 04:03 AM
How to trace a hotkey assignment that I did not create? Ken K Microsoft Windows 2000 0 14th Nov 2003 06:30 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:23 PM.