Solved

KeyCode combination

Posted on 2002-04-19
7
584 Views
Last Modified: 2012-05-05
I use the following code to run cmdGoToNext_Click when F10 is pressed:

-----------------------------------------------------
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
   
    If KeyCode = vbKeyF10 And cmdGoToNext.Visible = True Then
        cmdGoToNext_Click
    End If
   
End Sub
------------------------------------------------------

What should the code be to use Ctrl & Right Arrow together instead of F10?

Thanks.
0
Comment
Question by:naqayya
[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
  • 3
  • 2
  • 2
7 Comments
 
LVL 18

Expert Comment

by:deighton
ID: 6953333
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
   
   If (KeyCode = 39 and shift = 2) And cmdGoToNext.Visible = True Then
       cmdGoToNext_Click
   End If
   
End Sub
0
 
LVL 18

Expert Comment

by:deighton
ID: 6953350
more properly it is

If KeyCode = vbKeyRight And CBool(Shift And vbCtrlMask) Then
   
    MsgBox "YES"
   
End If
0
 

Author Comment

by:naqayya
ID: 6953404
deighton:

Both your solutions don't seem to work. When I use the first solution I get an error message, and the second just does an ordinary move right (to next field).

My code is:

-----------------------------------------------------
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
   
    If (KeyCode = vbKeyLeft And CBool(Shift And vbCtrlMask)) And (cmdGoToNext.Visible = True) Then
        cmdGoToNext_Click
   
    End If
   
End Sub


Private Sub cmdGoToNext_Click()

    Check_Allocations
   
    If StopCodeExecution = True Then
        StopCodeExecution = False
        Exit Sub
    Else
        DoCmd.GoToRecord acDataForm, "frmDonations", acNext
    End If

End Sub
______________________________________________________

Can you help? Thanks.
0
Independent Software Vendors: 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!

 
LVL 18

Expert Comment

by:deighton
ID: 6953598
sorry dude, I guess that the arrow key still carries out its function regardless.  I don't know how to stop that behaviour.

Feel free to delete the question and repost it if you want
0
 
LVL 57

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 50 total points
ID: 6953606
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)

  Dim intCtrlDown As Integer

  intCtrlDown = (Shift And acCtrlMask) > 0
  If KeyCode = vbKeyRight And intCtrlDown = True And cmdGoToNext.Visible = True Then
     call cmdGoToNext_Click
   End If

End Sub

Jim.
0
 

Author Comment

by:naqayya
ID: 6953717
deighton: Thanks for that.

Jim: It works! Thanks again. BTW, can use a boolean type for intCtrlDown?
0
 
LVL 57
ID: 6953915
<<BTW, can use a boolean type for intCtrlDown? >>

 Not sure.  I've never tried it that way.  True/false in Access is an integer type (-1/0).  I've generally stayed away from the boolean type and implicit logic checks because of past bugs.

Jim.
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

737 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