Jack Marley
asked on
MS Access Form - Report from selected records and send to printer
Hi,
I have a piece of VBA code written for me which outputs selected records as pdf reports.
Is it possible to amend the code so that instead of exporting as a PDF, it will print through the default printer?
All my attempts so far just print the active object ie the form itself.
Here's what I currently have:
Any help would be greatly appreciated.
Thanks!
I have a piece of VBA code written for me which outputs selected records as pdf reports.
Is it possible to amend the code so that instead of exporting as a PDF, it will print through the default printer?
All my attempts so far just print the active object ie the form itself.
Here's what I currently have:
Private Sub Command28_Click()
DoCmd.RunCommand acCmdSaveRecord
Forms!InvoiceNoEmail.SetFocus
Dim oApp As Object
Dim oEmail As Outlook.MailItem
Dim fileName As String
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("SELECT [Account], [InvoiceNum], [EmailAddress], [Company], [Printed] FROM [ContactTotalsNoEmail] WHERE (((Contracts.SelectedPrint)=True)) ORDER BY [Account];", dbOpenDynaset)
Do While Not rst.EOF
strRptFilter = "[InvoiceNum] = " & Chr(34) & rst![InvoiceNum] & Chr(34)
DoCmd.PrintOut
fileName = "C:\Scripts\NoEmail" & "\" & rst![Account] & " - " & rst![InvoiceNum] & ".pdf"
DoCmd.OutputTo acOutputReport, "InvTotalNoEmail", acFormatPDF, fileName
rst.Edit
rst![Printed] = "Yes"
rst.Update
DoEvents
rst.MoveNext
Loop
rst.Close
Set rst = Nothing
Forms!InvoiceNoEmail.Requery
End Sub
Any help would be greatly appreciated.
Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You're welcome.
ASKER