Solved

KeyCode combination

Posted on 2002-04-19
7
572 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
  • 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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
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…

823 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