Assign Ctrl+P for Print Command in VBA instead of Alt+P

accessonly11

Member
Local time
Today, 11:34
Joined
Aug 20, 2022
Messages
91
dears
how it could be possible to assign ctrl + p key to call print command event through vba, instead of using hotkeys.
thanks
 
create a macro and name it Autokeys.
see this demo using Ctrl+P.
be warned that this macro overrides the default behavior of Ctrl+P (print).
 

Attachments

create a macro and name it Autokeys.
see this demo using Ctrl+P.
be warned that this macro overrides the default behavior of Ctrl+P (print).
yes i want to disable default ctrl+p behaviour. and assign it to a command button
 
here is some code that can easily be adapted to specifically disable ctrl-p

as to assigning 'print' to a command button, depends on what you want to print and how, but to open the print dialog box use

DoCmd.RunCommand acCmdPrint
 
You can assign our own preferred shortcuts to many actions using an autokeys macro.

However in this case, there is no need as Ctrl+P is already used to open the Print dialog.
Keyboard shortcuts for Access - Microsoft Support
I am unable to assign "call button click event" action using an autokeys macro. To assign an action to ctrl+p keys combination, i am using this code

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyRight
Call cmdNext_Click
Case vbKeyLeft
Call cmdPrevious_Click
Case Shift = acCtrlMask And vbKeyP
Call cmdInvoice_Click
Case Else
End Select
End Sub

but when ever i press keys combinations for second time it open default print dialog box, how to disable this permanently.
 

Users who are viewing this thread

Back
Top Bottom