Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

printing

Hello :WAVE: ,
I need to ask a question

How do I print to my NON Defult printer from VB (I am printing a Access reports)

I have the following printers installed

Pick_list (\\printer_server\picklist)
Invoice (\\printer_server\Invoice)
window_printer (\\printer_server\windows) ** Defult printer **

I need to print to all differnt printers

Can some one HELP me please as I have some very big reports and I can not get the layout the same with in VB print commands

I need to print the access reports (witch I can BUT it only prints to my DEFULT Printer)

Can someone help me with some advice or code examples?

Thanks in advance

Drew
[723 byte] By [Drew_gable] at [2007-11-11 6:33:01]
# 1 Re: printing
how do you print? by the Printer object or by a reporter control?
Marco
mstraf at 2007-11-11 17:28:20 >
# 2 Re: printing
I am printing it via code that I was given on here
Drew_gable at 2007-11-11 17:29:20 >
# 3 Re: printing
because I am not "here" I cannot know it :)
please be more specific

Marco
mstraf at 2007-11-11 17:30:18 >
# 4 Re: printing
As Marco is asking, which method of printing are you using?

If using the printer object, you can loop through the Printers collection looking for a particular DeviceName, and select the printer you want :-

Dim P As Printer
For Each P In Printers
If P.DeviceName = MyDesiredPrinter Then
Set Printer = P
bPrinterFound = True ' you may want to indicate that you found the printer u r looking for
Exit For
End If
Next P
gupex at 2007-11-11 17:31:20 >
# 5 Re: printing
Well you see I have no idea as to what methold I am using.

I am printing the report by the means of the following code

Dim AppAccess As Access.Application
Dim DatabaseName As String
Set AppAccess = New Access.Application
On Error GoTo ErrorPrinting

DatabaseName = App.Path + "\Products.mdb"
AppAccess.OpenCurrentDatabase (DatabaseName)
AppAccess.DoCmd.OpenReport "Re_order_stock_report", acViewNormal
AppAccess.CloseCurrentDatabase
Set AppAccess = Nothing
Screen.MousePointer = vbDefault
Exit Sub

ErrorPrinting:
MsgBox "Error printing Report: " & CStr(Err.Number) & Err.Description, _
vbInformation, "Error"
Err.Clear
Exit Sub

the Problem with this code is that it ONLY prints to the defult printer (the windows printer) But I need to have selected reports print to different printers

is there a simpler way of printing a access report or do i need to use the in build report functions that come with VB6?
Drew_gable at 2007-11-11 17:32:19 >
# 6 Re: printing
from your code you are using the OpenReport method. Sorry I do not use Access, thus I can't help in this one, but I know that Access is widly used by people in this forum. Try also to see the msdn documentation for OpenReport (or google it) to see how to print to another printer.
BTW Greg's suggestion to change the Printer object before calling DoReport should work as well.
Good luck,
Marco
mstraf at 2007-11-11 17:33:18 >