Results 1 to 14 of 14

Thread: [Resolved] Change printer in Access 2000

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2001
    Location
    Indiana
    Posts
    612

    [Resolved] Change printer in Access 2000

    I am using the following code on a command button in an Access 2000 program.

    Code:
    Dim x As Printer
    
    For Each x In Printers
        If x.DeviceName = "Acrobat Distiller" Then
            Set Printer = x
            Exit For
        End If
    Next
    
    DoCmd.OpenReport "Prop_Invoice_Email", acViewPreview, , "Month(Inv_Statement_Date) = " _
    & Format(Month(dteStatementDate), "00") & " And Year(Inv_Statement_Date) = " & _
    Format(Year(dteStatementDate), "00")
    
    DoCmd.PrintOut acPrintAll, , , acHigh
    I want this report to print out to my Acrobat Distiller printout but it is printing to my system default printer.

    Anyone have any ideas why this is happening?

    Thanks
    Last edited by indydavid32; Jun 30th, 2003 at 11:56 AM.
    David Wilhelm

  2. #2

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2001
    Location
    Indiana
    Posts
    612

    Unhappy Bump

    Bump
    David Wilhelm

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2001
    Location
    Indiana
    Posts
    612

    Angry Help!

    Can anyone answer this?

    Anyone at all?

    PLEASE!
    David Wilhelm

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2001
    Location
    Indiana
    Posts
    612

    Bump

    Bump
    David Wilhelm

  5. #5
    Frenzied Member swatty's Avatar
    Join Date
    Aug 2002
    Location
    somewhere on earth
    Posts
    1,478
    you have to set the default printer to your choice , print the report and reset the default printer.

    Or you have to set the printer in the report to this printer.

    If no special printer is set in the report it prints to the default printer.
    Code:
    If Question = Incomplete Then
       AnswerNextOne
    Else
       ReplyIfKnown
    End If
    cu Swatty

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2001
    Location
    Indiana
    Posts
    612

    I am setting the printer

    If you look at my first post, you can see that I am trying to set the printer to the Acrobat Distiller.

    When I print my report, it does not print to the Acrobat Distiller, it prints to my system default printer.

    That was my question, why is it doing this.
    David Wilhelm

  7. #7
    Frenzied Member swatty's Avatar
    Join Date
    Aug 2002
    Location
    somewhere on earth
    Posts
    1,478
    I don't think you can set the printer like that.

    You need to set the currentdevice in de deviceslist to that printer.
    Code:
    If Question = Incomplete Then
       AnswerNextOne
    Else
       ReplyIfKnown
    End If
    cu Swatty

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2001
    Location
    Indiana
    Posts
    612

    Angry Bueler?.... Bueler?....Bueler?.....Bueler?

    Can anyone give a definite answer why my code won't work and an example of some code that does work?

    Thanks
    David Wilhelm

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2001
    Location
    Indiana
    Posts
    612

    Unhappy Bump

    Surely someone knows the answer to this.
    David Wilhelm

  10. #10
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951
    I have a coupe report that just use printer.printy. However this is the code they use to sdelect the printer:

    ' MsgBox "Set default printer to server. Make sure paper size is set to FANFOLD1.", vbInformation
    ' CommonDialog1.ShowPrinter
    SCREEN.MousePointer = vbHourglass
    Printer.Orientation = vbPRORLandscape
    MonthlyActivity
    Printer.Orientation = vbPRORLandscape
    MonthlyActivity2
    SCREEN.MousePointer = 0
    Printer.Orientation = vbPRORPortrait
    ' MsgBox "Set default printer back to what it was.", vbInformation
    ' CommonDialog1.ShowPrinter

  11. #11
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951
    Also, have you used the debug to see what printer names it is actually finding? If it doesn't find the name you have specified, it will go to the default. By the way, forget the comment marks on the previous post before the commondialog statement.

  12. #12
    New Member
    Join Date
    Sep 2002
    Location
    Fantasia, Castle Donnington 1993
    Posts
    8
    Try this:

    Dim stDocName As String

    Dim x As Printer

    'Set the printer default

    Set Application.Printer = Application.Printers("Acrobat Distiller")

    Set x = Application.Printer

    'Opens Prop Invoice Email in preview mode and then sets the reports printer to above printer

    stDocName = "Prop Invoice Email"
    DoCmd.OpenReport stDocName, acPreview, , , acWindowNormal

    Reports(stDocName).Printer = x

    DoCmd.PrintOut acPrintAll, , , acHigh

    When you set the Application.Printer you may require the full UNC path.

    Any problems let me know.

  13. #13
    New Member
    Join Date
    Sep 2002
    Location
    Fantasia, Castle Donnington 1993
    Posts
    8
    Did it work ????

  14. #14

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2001
    Location
    Indiana
    Posts
    612

    Went another way

    Hi, thanks for your post. I don't know if it worked or not. I went another way.

    Instead of using the distiller, I am exporting it directly to a file using the following code using my VB code.

    VB Code:
    1. Screen.MousePointer = vbHourglass
    2. CRViewer1.ReportSource = Report
    3. Report.Database.Tables(1).SetLogOnInfo "12.23.12.12", "Monthly Invoices", "sa", ""
    4. Report.DiscardSavedData
    5. CRViewer1.ReportSource = Report
    6.  
    7. CRViewer1.ViewReport
    8. CRViewer1.Zoom 90
    9. Report.SaveAs "C:\Statement.rpt", cr80FileFormat
    10.  
    11. Dim objCrstal As New CRAXDRT.Application
    12. Dim objReport As New CRAXDRT.Report
    13. Dim objExportOptions As CRAXDRT.ExportOptions
    14.  
    15. Set objCrystal = New CRAXDRT.Application
    16.  
    17. Set objReport = objCrystal.OpenReport("C:\Statement.rpt", 0)
    18. Set objExportOptions = objReport.ExportOptions
    19.  
    20. With objExportOptions
    21.     .DestinationType = crEDTDiskFile
    22.     .DiskFileName = "C:\Statement.pdf"
    23.     .FormatType = crEFTPortableDocFormat
    24.     .PDFExportAllPages = True
    25. End With
    26.  
    27. objReport.Export False
    28.  
    29. Set objReport = Nothing
    30. Set objCrystal = Nothing
    31. Screen.MousePointer = vbDefault
    David Wilhelm

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width