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.
SweetingAAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rey Obrero (Capricorn1)Commented:
try

application.SendKeys("^P")
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
IrogSintaCommented:
You can use:
DoCmd.RunCommand acCmdPrint
However, don't you think it would be much better to create a dedicated report and adding a print button on a form to print this report.  Not only would the report be more professional looking, you would also use less toner/ink since you would avoid printing the GUI each time.

Ron
0
SweetingAAuthor Commented:
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).SetFocus
        DoCmd.PrintOut acPrintAll
    Next x
   
    Me.TabCtl0.Pages(0).SetFocus
    Me.FilterOn = False
   
Exit_PrintDocument_Click:
    Exit Sub

Err_PrintDocument_Click:
    MsgBox Err.Description
    Resume Exit_PrintDocument_Click
   
End Sub
0
IrogSintaCommented:
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.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.