Good morning everyone. Can someone please tell me how to code: When CTRL-b is pressed do a procedure. Thanks you to anyone who helps, I really hate dead lines.
Paste this into the Declarations section of your form:
Dim booControlKeyPressed As Boolean
Paste this into the On Load event of your form:
booControlKeyPressed = False
Paste this into the On Key Down event of your form:
If KeyCode = vbKeyControl Then
booControlKeyPressed = True
End If
If booControlKeyPressed = True Then
If KeyCode = vbKeyB Then
MsgBox "Ctrl + B was pressed!"
gControlKeyPressed = False
ElseIf KeyCode = vbKeyC Then
MsgBox "Ctrl + C was pressed!"
gControlKeyPressed = False
End If
End If
If KeyCode <> vbKeyControl Then
booControlKeyPressed = False
End If
Paste this into the On Key Up event of your form:
If KeyCode = vbKeyControl Then
booControlKeyPressed = False
End If
You will need to set the Key Preview property of the form to Yes.
Assuming this works, you should easily be able to convert this into a Public Procedure available to all your forms.
Thank you very much Bill. I will try this but I have a 2 line procedure, where would I put this? Also I don't think I need this to be public, it is a subform, which is used in two forms, that is it. Thank you again for the assistance, I do appreciate it.
I think your suggestion is excellent, much better than what I've previously used and suggested to quest4. (quest4, please disregard my suggestion and go with boriska40)
I tried this in the ON KeyDown event and I get a Missing Separator error, can any one tell me where I went wrong?
Hereis the code:
'Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Private Sub Text0_KeyDown(KeyCode As Integer, Shift As Integer)
Dim ControlDDown As Integer
ControlDDown = (KeyCode = vbKeyD And Shift And acCtrlMask) > 0
If ControlDDown = True Then
Me.PartGroup = Me.PartGroup + 1
ERROR-> Me.ItemNumber = Nz(DMax("[ItemNumber]","stblECN_BOM","[PartGroup]" = " & Me!PartGroup)) +1
End If
End Sub
I commented out the orginal in favor of the line Boriska40 gave me, which is correct? Thanks for the assistance.
Than you for the assistance boriska40. It turnout out to be an extra ". But it is not increasing the PartGroup by 1, it is like I never touched CTRL-b at all and I even tried pushing it 2 and 3 times and still nothing. Here is what I am using:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Dim ControlDDown As Integer
ControlDDown = (KeyCode = vbKeyD And Shift And acCtrlMask) > 0
If ControlDDown = True Then
Me.PartGroup = Me.PartGroup + 1
Me.ItemNumber = Nz(DMax("[ItemNumber]", "stblECN_BOM", "[PartGroup] = " & Me!PartGroup), 0) + 1
End If
End Sub
I also tried it with and without the shift key. When this works I am done, I hope. tahnk you so very much for all of the help.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.