Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Print Specifaclly

Status
Not open for further replies.

krnsmartazz

Technical User
Dec 13, 2001
134
US
I want a Report to print to a certain printer.
I want to do this programically.
My computer has 3 printers attached to it.
I want a form to pop up that displays the printers attached.
If a user selects that printer it will print there.
The problem I don't know the code that will display the printers attached.
I assume this code is very long.
 
Actually I want to create a custom form that displays the availible printers. Kinda like like the print dialog.
But automatically. I have the code to make the print dialog come up but I want to use a form. I can't get the code that will give me the avalible printers. I think you use API
 
If you are sending your reports directly to the printer (not previewing them), here is a way to get the Print Dialog Box to show so you can choose the printer settings. You will notice that the report is opened acPreview but don't worry, it will not become visible on screen. Just follow the instructions below.

Use DoCmd.OpenReport method to open the report:

DoCmd.OpenReport "YourReportNameHere", acViewPreview

Now open the Report in design view. Use the following code in the On Activate event of the Report:

Private Sub Report_Activate()
On Error Resume Next
Dim strMsg As String, strTitle As String
strMsg = "There Were No Records Returned for Criteria Entered."
strTitle = " No Matching Records"
If Me.HasData Then
  DoCmd.RunCommand acCmdPrint
  DoCmd.Close acReport, Me.Name
Else
  MsgBox strMsg, vbInformation + vbOKOnly, strTitle
  DoCmd.Close acReport, Me.Name
End If
End Sub

The above code also handles the problem if there are no records returned by recordset. So you don't have to use the On No Data event.

The code will cause the Print Dialog Box to open so you can change the print settings, the Report will then print and close ..... without the Report ever becoming visible on screen.

HTH
RDH

Ricky Hicks
Birmingham, Alabama


 
that is a great way!! thanks

is there code that will get me a list od installed printers. then allow me to assign the printers to different reports?

Thanks in advance
 
DIM myPrinter as printer
for each myprinter in printers
me.list1.additem myprinter.devicename
next myprinter
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top