I want to run an event when I press the Ctl key simultaneously with the K
key. How do I achieve this in VBA?
dixie 8 2208
Hi, Dixie.
You can create a macro that will call a VBA function every time you hit a
certain key combination. Search Access Help for "AutoKeys."
HTH.
Gunny
See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.
(Please remove ZERO_SPAM from my reply E-mail address, so that a message
will be forwarded to me.)
"dixie" <di****@dogmail.com> wrote in message
news:lO***************@nnrp1.ozemail.com.au... I want to run an event when I press the Ctl key simultaneously with the K key. How do I achieve this in VBA?
dixie
I know that 69 Camaro, but it is a bit too open in a macro. I want to do it
in vba within a module if I can.
dixie
"'69 Camaro" <Fo**************************@Spameater.orgZERO_SP AM> wrote in
message news:bZt0d.744$bj2.108@trnddc08... Hi, Dixie.
You can create a macro that will call a VBA function every time you hit a certain key combination. Search Access Help for "AutoKeys."
HTH.
Gunny
See http://www.QBuilt.com for all your database needs. See http://www.Access.QBuilt.com for Microsoft Access tips.
(Please remove ZERO_SPAM from my reply E-mail address, so that a message will be forwarded to me.)
"dixie" <di****@dogmail.com> wrote in message news:lO***************@nnrp1.ozemail.com.au... I want to run an event when I press the Ctl key simultaneously with the
K key. How do I achieve this in VBA?
dixie
I forgot to mention that you can also use the KeyDown( ) event on a form to
determine which keys where pressed, and if they are the correct combination,
then the KeyDown( ) event can execute your VBA procedure. However, this
will only be effective in the current form, whereas the AutoKeys macro will
be global and can be used for all database objects.
HTH.
Gunny
See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.
(Please remove ZERO_SPAM from my reply E-mail address, so that a message
will be forwarded to me.)
"'69 Camaro" <Fo**************************@Spameater.orgZERO_SP AM> wrote in
message news:bZt0d.744$bj2.108@trnddc08... Hi, Dixie.
You can create a macro that will call a VBA function every time you hit a certain key combination. Search Access Help for "AutoKeys."
HTH.
Gunny
See http://www.QBuilt.com for all your database needs. See http://www.Access.QBuilt.com for Microsoft Access tips.
(Please remove ZERO_SPAM from my reply E-mail address, so that a message will be forwarded to me.)
"dixie" <di****@dogmail.com> wrote in message news:lO***************@nnrp1.ozemail.com.au... I want to run an event when I press the Ctl key simultaneously with the
K key. How do I achieve this in VBA?
dixie
So how do I tell it that Ctrl K has been pressed. If I can find that out, I
can work the rest out for myself (hopefully).
dixie
"'69 Camaro" <Fo**************************@Spameater.orgZERO_SP AM> wrote in
message news:gbu0d.761$bj2.431@trnddc08... I forgot to mention that you can also use the KeyDown( ) event on a form
to determine which keys where pressed, and if they are the correct
combination, then the KeyDown( ) event can execute your VBA procedure. However, this will only be effective in the current form, whereas the AutoKeys macro
will be global and can be used for all database objects.
HTH.
Gunny
See http://www.QBuilt.com for all your database needs. See http://www.Access.QBuilt.com for Microsoft Access tips.
(Please remove ZERO_SPAM from my reply E-mail address, so that a message will be forwarded to me.)
"'69 Camaro" <Fo**************************@Spameater.orgZERO_SP AM> wrote
in message news:bZt0d.744$bj2.108@trnddc08... Hi, Dixie.
You can create a macro that will call a VBA function every time you hit
a certain key combination. Search Access Help for "AutoKeys."
HTH.
Gunny
See http://www.QBuilt.com for all your database needs. See http://www.Access.QBuilt.com for Microsoft Access tips.
(Please remove ZERO_SPAM from my reply E-mail address, so that a message will be forwarded to me.)
"dixie" <di****@dogmail.com> wrote in message news:lO***************@nnrp1.ozemail.com.au... I want to run an event when I press the Ctl key simultaneously with
the K key. How do I achieve this in VBA?
dixie
Here's a little bit of code added to the example in Access Help for the
KeyDown event to show how to determine whether the correct keys were
pressed:
Private Sub KeyHandler_KeyDown(KeyCode As Integer, _
Shift As Integer)
Dim intShiftDown As Integer, intAltDown As Integer
Dim intCtrlDown As Integer
' Use bit masks to determine which key was pressed.
intShiftDown = (Shift And acShiftMask) > 0
intAltDown = (Shift And acAltMask) > 0
intCtrlDown = (Shift And acCtrlMask) > 0
' Display message telling user which key was pressed.
If (intShiftDown And (Chr(KeyCode) = "k")) Then
MsgBox "You pressed the SHIFT key and the " & _
Chr(KeyCode) & " key."
End If
If (intAltDown And (Chr(KeyCode) = "k")) Then
MsgBox "You pressed the ALT key and the " & _
Chr(KeyCode) & " key."
End If
If (intCtrlDown And (Chr(KeyCode) = "k")) Then
MsgBox "You pressed the CTRL key and the " & _
Chr(KeyCode) & " key."
End If
End Sub
HTH.
Gunny
See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.
(Please remove ZERO_SPAM from my reply E-mail address, so that a message
will be forwarded to me.)
"dixie" <di****@dogmail.com> wrote in message
news:ic****************@nnrp1.ozemail.com.au... So how do I tell it that Ctrl K has been pressed. If I can find that out,
I can work the rest out for myself (hopefully).
dixie
"'69 Camaro" <Fo**************************@Spameater.orgZERO_SP AM> wrote
in message news:gbu0d.761$bj2.431@trnddc08... I forgot to mention that you can also use the KeyDown( ) event on a form to determine which keys where pressed, and if they are the correct combination, then the KeyDown( ) event can execute your VBA procedure. However, this will only be effective in the current form, whereas the AutoKeys macro will be global and can be used for all database objects.
HTH.
Gunny
See http://www.QBuilt.com for all your database needs. See http://www.Access.QBuilt.com for Microsoft Access tips.
(Please remove ZERO_SPAM from my reply E-mail address, so that a message will be forwarded to me.)
"'69 Camaro" <Fo**************************@Spameater.orgZERO_SP AM> wrote in message news:bZt0d.744$bj2.108@trnddc08... Hi, Dixie.
You can create a macro that will call a VBA function every time you
hit a certain key combination. Search Access Help for "AutoKeys."
HTH.
Gunny
See http://www.QBuilt.com for all your database needs. See http://www.Access.QBuilt.com for Microsoft Access tips.
(Please remove ZERO_SPAM from my reply E-mail address, so that a
message will be forwarded to me.)
"dixie" <di****@dogmail.com> wrote in message news:lO***************@nnrp1.ozemail.com.au... > I want to run an event when I press the Ctl key simultaneously with the K > key. How do I achieve this in VBA? > > dixie > >
Hi Dixie,
I tried the code segment offered by 69camaro and couldn't make it work, it
didn't seem to recognize the Chr(KeyCode) = "k") logic. I ended up with
something very simplistic but it may be a place to start. Recognizing a
keyhit on a form rather than a control:
' must set form key preview event = yes
Private Sub Form_KeyPress(KeyAscii As Integer)
MsgBox KeyAscii
End Sub
This event will be triggered when hitting any key while the form has focus.
I tried SHIFT 'a' (i.e. uppercase A) and got 65, tried 'a' (i.e. lowercase
a) and got 97, tried CONTROL 'a' and got 1. CONTROL 'k' yields 11.
HTH -Linda
"'69 Camaro" <Fo**************************@Spameater.orgZERO_SP AM> wrote in
message news:1Nu0d.1048$MS1.585@trnddc02... Here's a little bit of code added to the example in Access Help for the KeyDown event to show how to determine whether the correct keys were pressed:
Private Sub KeyHandler_KeyDown(KeyCode As Integer, _ Shift As Integer) Dim intShiftDown As Integer, intAltDown As Integer Dim intCtrlDown As Integer
' Use bit masks to determine which key was pressed.
intShiftDown = (Shift And acShiftMask) > 0 intAltDown = (Shift And acAltMask) > 0 intCtrlDown = (Shift And acCtrlMask) > 0
' Display message telling user which key was pressed.
If (intShiftDown And (Chr(KeyCode) = "k")) Then MsgBox "You pressed the SHIFT key and the " & _ Chr(KeyCode) & " key." End If
If (intAltDown And (Chr(KeyCode) = "k")) Then MsgBox "You pressed the ALT key and the " & _ Chr(KeyCode) & " key." End If
If (intCtrlDown And (Chr(KeyCode) = "k")) Then MsgBox "You pressed the CTRL key and the " & _ Chr(KeyCode) & " key." End If End Sub
HTH.
Gunny
See http://www.QBuilt.com for all your database needs. See http://www.Access.QBuilt.com for Microsoft Access tips.
(Please remove ZERO_SPAM from my reply E-mail address, so that a message will be forwarded to me.)
"dixie" <di****@dogmail.com> wrote in message news:ic****************@nnrp1.ozemail.com.au... So how do I tell it that Ctrl K has been pressed. If I can find that
out, I can work the rest out for myself (hopefully).
dixie
"'69 Camaro" <Fo**************************@Spameater.orgZERO_SP AM> wrote in message news:gbu0d.761$bj2.431@trnddc08... I forgot to mention that you can also use the KeyDown( ) event on a
form to determine which keys where pressed, and if they are the correct combination, then the KeyDown( ) event can execute your VBA procedure. However,
this will only be effective in the current form, whereas the AutoKeys macro will be global and can be used for all database objects.
HTH.
Gunny
See http://www.QBuilt.com for all your database needs. See http://www.Access.QBuilt.com for Microsoft Access tips.
(Please remove ZERO_SPAM from my reply E-mail address, so that a
message will be forwarded to me.)
"'69 Camaro" <Fo**************************@Spameater.orgZERO_SP AM>
wrote in message news:bZt0d.744$bj2.108@trnddc08... > Hi, Dixie. > > You can create a macro that will call a VBA function every time you hit a > certain key combination. Search Access Help for "AutoKeys." > > HTH. > > Gunny > > See http://www.QBuilt.com for all your database needs. > See http://www.Access.QBuilt.com for Microsoft Access tips. > > (Please remove ZERO_SPAM from my reply E-mail address, so that a message > will be forwarded to me.) > > > "dixie" <di****@dogmail.com> wrote in message > news:lO***************@nnrp1.ozemail.com.au... > > I want to run an event when I press the Ctl key simultaneously
with the K > > key. How do I achieve this in VBA? > > > > dixie > > > > > >
"dixie" <di****@dogmail.com> wrote in message news:<lO***************@nnrp1.ozemail.com.au>... I want to run an event when I press the Ctl key simultaneously with the K key. How do I achieve this in VBA?
dixie
You need to create a macro and save the macro as autokeys.
In the macro use the macro name e.g. {F9} so that the macro will run
when F9 is pressed.
The macro then then run the code you want.
Alex
Hi, Linda. I tried the code segment offered by 69camaro and couldn't make it work, it didn't seem to recognize the Chr(KeyCode) = "k") logic.
I that suspect you were trying to use the example on an object other than a
control that accepts keyboard input. I tested the code on Access 97, 2K,
and '03, and they all worked perfectly, so I didn't have any reason to
suspect that this example wouldn't also work in Access XP.
Try opening a form in Design View, then create a text box named KeyHandler
(as provided in Microsoft's example from Help), then paste the code I
offered in my previous post into the form's module. Save and compile.
If Access doesn't automatically set the "On Key Down" event property to
[Event Procedure], then set it manually with your mouse, and make sure that
the name of the control is KeyHandler. (If Access creates a new event
procedure instead of opening the module at the code you pasted in, then
either the text box name is misspelled or the wrong event has been selected
with the mouse.) Save the form again if you made changes.
Open the form in Form View. Now hold down either the <CTRL>, <SHIFT>, or
<ALT> key down, then press the <k> key and see whether the message box pops
up telling you which keys you pressed.
Please post back if you have further problems.
HTH.
Gunny
See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.
(Please remove ZERO_SPAM from my reply E-mail address, so that a message
will be forwarded to me.)
"Squirrel" <wi*****@covad.net> wrote in message
news:b3**************************@msgid.meganewsse rvers.com... Hi Dixie,
I tried the code segment offered by 69camaro and couldn't make it work, it didn't seem to recognize the Chr(KeyCode) = "k") logic. I ended up with something very simplistic but it may be a place to start. Recognizing a keyhit on a form rather than a control:
' must set form key preview event = yes Private Sub Form_KeyPress(KeyAscii As Integer) MsgBox KeyAscii End Sub
This event will be triggered when hitting any key while the form has
focus. I tried SHIFT 'a' (i.e. uppercase A) and got 65, tried 'a' (i.e. lowercase a) and got 97, tried CONTROL 'a' and got 1. CONTROL 'k' yields 11.
HTH -Linda
"'69 Camaro" <Fo**************************@Spameater.orgZERO_SP AM> wrote
in message news:1Nu0d.1048$MS1.585@trnddc02... Here's a little bit of code added to the example in Access Help for the KeyDown event to show how to determine whether the correct keys were pressed:
Private Sub KeyHandler_KeyDown(KeyCode As Integer, _ Shift As Integer) Dim intShiftDown As Integer, intAltDown As Integer Dim intCtrlDown As Integer
' Use bit masks to determine which key was pressed.
intShiftDown = (Shift And acShiftMask) > 0 intAltDown = (Shift And acAltMask) > 0 intCtrlDown = (Shift And acCtrlMask) > 0
' Display message telling user which key was pressed.
If (intShiftDown And (Chr(KeyCode) = "k")) Then MsgBox "You pressed the SHIFT key and the " & _ Chr(KeyCode) & " key." End If
If (intAltDown And (Chr(KeyCode) = "k")) Then MsgBox "You pressed the ALT key and the " & _ Chr(KeyCode) & " key." End If
If (intCtrlDown And (Chr(KeyCode) = "k")) Then MsgBox "You pressed the CTRL key and the " & _ Chr(KeyCode) & " key." End If End Sub
HTH.
Gunny
See http://www.QBuilt.com for all your database needs. See http://www.Access.QBuilt.com for Microsoft Access tips.
(Please remove ZERO_SPAM from my reply E-mail address, so that a message will be forwarded to me.)
"dixie" <di****@dogmail.com> wrote in message news:ic****************@nnrp1.ozemail.com.au... So how do I tell it that Ctrl K has been pressed. If I can find that out, I can work the rest out for myself (hopefully).
dixie
"'69 Camaro" <Fo**************************@Spameater.orgZERO_SP AM>
wrote in message news:gbu0d.761$bj2.431@trnddc08... > I forgot to mention that you can also use the KeyDown( ) event on a form to > determine which keys where pressed, and if they are the correct combination, > then the KeyDown( ) event can execute your VBA procedure. However, this > will only be effective in the current form, whereas the AutoKeys
macro will > be global and can be used for all database objects. > > HTH. > > Gunny > > See http://www.QBuilt.com for all your database needs. > See http://www.Access.QBuilt.com for Microsoft Access tips. > > (Please remove ZERO_SPAM from my reply E-mail address, so that a
message > will be forwarded to me.) > > > "'69 Camaro" <Fo**************************@Spameater.orgZERO_SP AM> wrote in > message news:bZt0d.744$bj2.108@trnddc08... > > Hi, Dixie. > > > > You can create a macro that will call a VBA function every time
you hit a > > certain key combination. Search Access Help for "AutoKeys." > > > > HTH. > > > > Gunny > > > > See http://www.QBuilt.com for all your database needs. > > See http://www.Access.QBuilt.com for Microsoft Access tips. > > > > (Please remove ZERO_SPAM from my reply E-mail address, so that a message > > will be forwarded to me.) > > > > > > "dixie" <di****@dogmail.com> wrote in message > > news:lO***************@nnrp1.ozemail.com.au... > > > I want to run an event when I press the Ctl key simultaneously with the > K > > > key. How do I achieve this in VBA? > > > > > > dixie > > > > > > > > > > > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Jeremy |
last post by:
Hi, I am having a problem running an sql stored procedure with
ADO/ASP. If I hard code a select statement, the code works, but when
I try to use a stored procedure it bombs. Here is my code:
...
|
by: Mark Dicken |
last post by:
Hi All
I have found the following Microsoft Technet 'Q'
Article :-
Q210368 -ACC2000: How to Pass an Array as an Argument to a Procedure
(I've also copied and pasted the whole contents into...
|
by: deko |
last post by:
I have a sub routine that searches the Outlook PST for a message sent
to/from a particular email address. Obviously, this can take a long time
when the PST contains thousands of messages. I'd...
|
by: TB |
last post by:
Hi all:
If you think that the following comments are absolute amateurish, then
please bear with me, or simply skip this thread.
A couple of months back I made the decision to initiate a...
|
by: Mrkrich |
last post by:
I have one procedure that will take very long time before
it finishs. During its running, I provide users a button
to cancel this process if they don't want it to run
anymore.
I have one varible...
|
by: Clark Stevens |
last post by:
I just finished a WinForms app in VB.NET. I want to allow the user to be
able to run multiple instances of the program like you can with Notepad and
Wordpad. The way it is now, once I run the...
|
by: nishi57 |
last post by:
I hope I can get some help regarding this issue, which has been going
on for a while. I have a desktop user who is having problem running
"Stored Procedures". The DB2 Connect application works fine...
|
by: Antoine P. |
last post by:
Hello there -
I've got the following problem: my C# app (an .exe using different
dlls) has a different behaviour regarding the way I launch it.
The right behaviour when I press F5 from Visual C#...
|
by: Orit |
last post by:
Hi .
I am creating an ASP.NET 2.0 web site and have the following problem :
1. I have a GridView which bound to the object data source.
2. This object data source is SQL Table adapter that I...
|
by: DJRhino |
last post by:
Was curious if anyone else was having this same issue or not....
I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: giovanniandrean |
last post by:
The energy model is structured as follows and uses excel sheets to give input data:
1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
|
by: Teri B |
last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course.
0ne-to-many. One course many roles.
Then I created a report based on the Course form and...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM)
Please note that the UK and Europe revert to winter time on...
|
by: nia12 |
last post by:
Hi there,
I am very new to Access so apologies if any of this is obvious/not clear.
I am creating a data collection tool for health care employees to complete. It consists of a number of...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
|
by: isladogs |
last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, Mike...
|
by: GKJR |
last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
| |