Solved

KeyCode combination

Posted on 2002-04-19
7
578 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Suggested Solutions

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

820 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