?
Solved

KeyCode combination

Posted on 2002-04-19
7
Medium Priority
?
602 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
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!

 
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 58

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 200 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 58
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
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…
Suggested Courses

752 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