SweetingA
asked on
Sending Keyboard Commands in Access VBA
I would like to send the equivelant of Ctrl+P in an on click event.
I am sure its simple but i cant find the correct codes.
all help most welocmes.
I am sure its simple but i cant find the correct codes.
all help most welocmes.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I have done that but i want to always select the windows default printer but my code does not work. It knows what the printer is but never assigns it, it just keeps defaulting to the one which was set as the default in the form (a pdf printer). I will paste the code i use below....
I thought sending cntl+p would at least allow the user to pick the printer.
Private Sub PrintDocument_Click()
On Error GoTo Err_PrintDocument_Click
Me.Dirty = False
Dim prt As Printer
Set Application.Printer = Nothing
Set prt = Application.Printer
Debug.Print "Current default printer: " & prt.DeviceName
Dim s As Long
s = Me.[Our Ref]
Me.Filter = "[Our Ref]=" & s
Me.FilterOn = True
Dim x As Integer
x = 0
For x = 0 To 2
Me.TabCtl0.Pages(x).SetFoc us
DoCmd.PrintOut acPrintAll
Next x
Me.TabCtl0.Pages(0).SetFoc us
Me.FilterOn = False
Exit_PrintDocument_Click:
Exit Sub
Err_PrintDocument_Click:
MsgBox Err.Description
Resume Exit_PrintDocument_Click
End Sub
I thought sending cntl+p would at least allow the user to pick the printer.
Private Sub PrintDocument_Click()
On Error GoTo Err_PrintDocument_Click
Me.Dirty = False
Dim prt As Printer
Set Application.Printer = Nothing
Set prt = Application.Printer
Debug.Print "Current default printer: " & prt.DeviceName
Dim s As Long
s = Me.[Our Ref]
Me.Filter = "[Our Ref]=" & s
Me.FilterOn = True
Dim x As Integer
x = 0
For x = 0 To 2
Me.TabCtl0.Pages(x).SetFoc
DoCmd.PrintOut acPrintAll
Next x
Me.TabCtl0.Pages(0).SetFoc
Me.FilterOn = False
Exit_PrintDocument_Click:
Exit Sub
Err_PrintDocument_Click:
MsgBox Err.Description
Resume Exit_PrintDocument_Click
End Sub
If your report is set to go to a specific printer, then just go into the design mode of the report , select the Page Setup tab on the ribbon, then select the Page Setup icon, then the Page tab in the dialog box, and choose Default Printer.
Ron