Results 1 to 2 of 2
  1. #1
    jo15765's Avatar
    jo15765 is offline Expert
    Windows XP Access 2000
    Join Date
    Nov 2010
    Location
    6 Feet Under
    Posts
    672

    Using VBA to print a report based off day of week


    I have this code:
    Code:
    Sub printReport()
    Dim sDate As String
    DoCmd.SetWarnings.False
    sDate = Format(Date, "ddd")
    If sDate = "Mon" Then
        DoCmd.OpenReport "Rpt_Monday", acViewPreview
    End If
    If sDate = "Tue" Then
        DoCmd.OpenReport "RPT_Tuesday", acViewPreview
    End If
    
    'here is where I try to print
    Dim prt As Printer
    Set prt = Application.Printer
    Application.Printer = Application.Printers("Lexmark")
    DoCmd.PrintOut
    Set Application.Printer = prt
    End Sub
    However I get a compile error on the prt As Printer saying User-Definted type not defined

    This is Access 2000, Win 7

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    A2000 does not have a Printer object or the Printers collection. They were added in A2002.

    Abert Kallal had some code that might help you.

    http://www.kallal.ca/msaccess/msaccess.html

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 09-19-2013, 10:18 AM
  2. Replies: 3
    Last Post: 03-11-2013, 05:11 PM
  3. Replies: 1
    Last Post: 12-03-2012, 03:15 PM
  4. Start a report on week 40 of a week count
    By aspitalnick in forum Reports
    Replies: 8
    Last Post: 11-28-2012, 04:53 PM
  5. Replies: 0
    Last Post: 02-22-2011, 05:04 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums