|
-
Apr 24th, 2002, 09:52 AM
#1
Thread Starter
Hyperactive Member
Access Changing the printer
Have you ever changed the default printer from code?
I need to change the default printer and then change it back to the original printer.
-
Apr 24th, 2002, 10:01 AM
#2
Fanatic Member
I use this to set the printer on a till that prints receipts.
VB Code:
Dim pPrinter As Printer
For Each pPrinter In Printers
If pPrinter.DeviceName = gstrReportPrinter Then
' Set printer as system default.
Set Printer = pPrinter
' Stop looking for a printer.
Exit For
End If
Next
The gstrReportPrinter is a string that holds the name of the printer I want to use.
I loop through the availablre printers and when I find the one I want set the printer object to use that one
Hope this Helps.
Gary Lowe 
VB6 (Enterprise) SP5
ADO 2.6
SQL Server 7 SP3
OK I know my spelling and grammer is crap so don't quote me on it!
To err is human to take the P! is only natural !!
Click on the top section of image for Marcus Miller website and bottom section of image for 'Run For Cover' sound clip

-
Apr 24th, 2002, 12:53 PM
#3
The Printer Object is supported in VB, but not (to my knowledge) in VBA, so Gary's code is not going to work for you.
-
Apr 24th, 2002, 03:15 PM
#4
Thread Starter
Hyperactive Member
What is wrong with this code? I want it to print to Acrobat and not the default printer.
Code:
Option Explicit
Private acc As Access.Application
Private Sub Command1_Click()
Dim pPrinter As Printer
Dim view As Long
Dim acdstl As String
acdstl = "Acrobat Distiller"
Set acc = New Access.Application
For Each pPrinter In Printers
If pPrinter.DeviceName = acdstl Then
' Set printer as system default.
Set Printer = pPrinter
' Stop looking for a printer.
Exit For
End If
Next
acc.OpenCurrentDatabase ("C:\Documents and Settings\ihayse\Desktop\Monthly\Member Reports.mdb")
acc.DoCmd.OpenReport "AB_Add-Drop by PCP Labels", acViewNormal 'acViewNormal means the report is just printed.
acc.CloseCurrentDatabase
Set acc = Nothing
End Sub
-
Apr 24th, 2002, 04:35 PM
#5
Thread Starter
Hyperactive Member
-
Apr 25th, 2002, 06:24 AM
#6
If you got it, post it....it could, and probably will, help someone else.
-
Apr 25th, 2002, 10:52 AM
#7
Thread Starter
Hyperactive Member
The code above will not print Access Reports. For some reason when it comes to print Access Reports they are going through the default printer. But if I say form1.printform it will send the form to the Distiller but not the Access Report.......
-
Apr 25th, 2002, 02:20 PM
#8
Thread Starter
Hyperactive Member
FYI
You can change the default printer for each and ever Access Report in the "Page Setup" of the report.....
-
Apr 25th, 2002, 02:26 PM
#9
Thanks!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|