Printer Dialog Box w/o Report Preview

jkfeagle

Codus Confusious
Local time
Today, 02:32
Joined
Aug 22, 2002
Messages
166
Is it possible to invoke the Printer Dialog box to print a report without ever actually opening the report? For example, DoCmd.OpenReport acNormal sends the report directly to the printer presumably without opening it (if it does open, it's too quick to see). I want the same functionality but with the ability to choose the printer. Any ideas?
 
You need to open the report using the "acViewPreview" argument.

Example:
Code:
DoCmd.OpenReport "YourReportName", acViewPreview

Now ... using the On Activate event of the form .. place the following:

Code:
Private Sub Report_Activate()

On Error Resume Next

Dim strMsg As String, strTitle As String

strMsg = "There is No Matching Record ID"

strTitle = " No Records Returned"


If Me.HasData Then

  DoCmd.RunCommand acCmdPrint

  DoCmd.Close acReport, Me.Name

Else

  MsgBox strMsg, vbExclamation + vbOKOnly, strTitle

  DoCmd.Close acReport, Me.Name

  Exit Sub

End If


End Sub

The above will cause the print dialog box to appear ...

The report will print to the chosen printer and close without ever becoming visible to the user ...

Hope this helps ...
 

Users who are viewing this thread

Back
Top Bottom