Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    Sep 2001
    Location
    Wellington, Wellington, New Zealand
    Posts
    181
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Print Letterhead and plain paper (Access 97)

    Hi

    I have a form letter report, which prints two pages. Is there are way to print the first page on letterhead (tray 1) and the 2nd page on plain paper (tray 2) for all the records.

    Regards
    WTH

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Print Letterhead and plain paper (Access 97)

    Not easily. It would be simpler for you to either print the pages separately or interleaf your stationery and second sheets.
    Charlotte

  3. #3
    Lounger
    Join Date
    Nov 2001
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Print Letterhead and plain paper (Access 97)

    This may help
    Function TwoTrayPrinting(ReportName As String) As Integer
    '
    ' Prints a report's page 1 from the upper tray
    ' and the remaining pages from the lower tray.
    ' NOTE: The report gets run twice, once for each tray.
    '
    ' Assumes: that the report has 999 or fewer pages.
    '
    ' Returns: TRUE = Success; FALSE = Error
    '
    Const MAX_PAGES = 999

    ' Open the report in DESIGN view
    On Error GoTo TTP_Error
    DoCmd.Echo False
    DoCmd.OpenReport ReportName, A_DESIGN

    ' Switch to upper tray and print first page
    SetReportTray Reports(ReportName), R_UPPER_TRAY
    DoCmd.PrintOut A_PAGES, 1, 1

    ' Switch to lower tray and print remaining pages
    SetReportTray Reports(ReportName), R_LOWER_TRAY
    DoCmd.PrintOut A_PAGES, 2, MAX_PAGES

    ' Close the report
    DoCmd.SetWarnings False
    DoCmd.Close A_REPORT, ReportName
    DoCmd.SetWarnings True
    DoCmd.Echo True
    'TwoTrayPrinting = True

    TTP_Exit:
    Exit Function

    TTP_Error:
    ' TwoTrayPrinting = False
    DoCmd.Echo False ' Restore screen echo
    Resume TTP_Exit

    End Function

  4. #4
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Print Letterhead and plain paper (Access 97)

    Hi Rich,
    You'll need to include the code for the SetReportTray routine and the definition of the various constants.
    Regards,
    Rory

    Microsoft MVP - Excel

  5. #5
    2 Star Lounger
    Join Date
    Sep 2001
    Location
    Wellington, Wellington, New Zealand
    Posts
    181
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Print Letterhead and plain paper (Access 97)

    Hi

    Thanks the input from everyone.

    I solved the problem in a very clunky way. I spotted earlier the code on twotrayprinting and modified it. For those interested, here is the code:

    Option Compare Database
    Option Explicit


    Type str_DEVMODE
    RGB As String * 94
    End Type

    Type type_DEVMODE
    strDeviceName As String * 16
    intSpecVersion As Integer
    intDriverVersion As Integer
    intSize As Integer
    intDriverExtra As Integer
    lngFields As Long
    intOrientation As Integer
    intPaperSize As Integer
    intPaperLength As Integer
    intPaperWidth As Integer
    intScale As Integer
    intCopies As Integer
    intDefaultSource As Integer
    intPrintQuality As Integer
    intColor As Integer

    intDuplex As Integer
    intResolution As Integer
    intTTOption As Integer
    intCollate As Integer
    strFormName As String * 16
    lngPad As Long
    lngBits As Long
    lngPW As Long
    lngPH As Long
    lngDFI As Long
    lngDFr As Long
    End Type

    Sub SetReportTray(R As Report, TrayNumber As Integer)
    ' Changes the tray number of a report that is opened in DESIGN mode
    Dim DM As type_DEVMODE
    Dim DevMode As str_DEVMODE
    Dim strDevModeExtra As String
    If Not IsNull(R.PrtDevMode) Then
    strDevModeExtra = R.PrtDevMode
    DevMode.RGB = strDevModeExtra
    LSet DM = DevMode
    DM.lngFields = DM.lngFields Or DM.intOrientation
    DM.intDefaultSource = TrayNumber
    LSet DevMode = DM
    Mid(strDevModeExtra, 1, 94) = DevMode.RGB
    R.PrtDevMode = strDevModeExtra
    End If
    End Sub

    Function TwoTray(ReportName As String) As Integer
    ' Prints a report's page 1 from the upper tray
    ' and the remaining pages from the lower tray.
    ' NOTE: The report gets run twice, once for each tray.
    ' Assumes: that the report has 999 or fewer pages.
    ' Returns: TRUE = Success; FALSE = Error

    Dim DB As Database
    Dim rst As Recordset
    Dim Strsql As String
    Dim Total As Integer

    Strsql = "SELECT DISTINCTROW [LastName] & ', ' & [FirstName] AS Actor"
    Strsql = Strsql + " FROM ([Program Types] RIGHT JOIN [Video Programs] ON"
    Strsql = Strsql + " [Program Types].ProgramTypeID = [Video Programs].ProgramTypeID) INNER JOIN (Actors INNER JOIN ProgramActorJoin ON Actors.ActorID = ProgramActorJoin.ActorID) ON [Video Programs].ProgramID = ProgramActorJoin.ProgramID;"

    Set DB = CurrentDb
    Set rst = DB.OpenRecordset(Strsql)
    Total = rst.RecordCount

    Const R_UPPER_TRAY = 271 'Letterhead
    Const R_LOWER_TRAY = 269 'Plain
    Const MAX_PAGES = 999
    ' Open the report in DESIGN view
    On Error GoTo TTP_Error
    Dim Page1
    Dim Page2

    Page1 = 1
    Page2 = 1
    Do While Page2 <= Total
    DoCmd.Echo False
    DoCmd.OpenReport ReportName, acDesign
    ' Switch to upper tray and print first page
    SetReportTray Reports(ReportName), R_UPPER_TRAY
    DoCmd.PrintOut A_PAGES, Page1, Page1
    ' Switch to lower tray and print remaining pages
    SetReportTray Reports(ReportName), R_LOWER_TRAY
    DoCmd.PrintOut A_PAGES, Page2, Page2
    DoCmd.SetWarnings False

    DoCmd.Close A_REPORT, ReportName
    DoCmd.SetWarnings True
    DoCmd.Echo True
    TwoTray = True
    Page1 = Page1 + 2
    Page2 = Page2 + 2
    Loop

    TTP_Exit:
    Exit Function

    TTP_Error:

    TwoTray = False
    DoCmd.Echo False ' Restore screen echo
    Resume TTP_Exit
    End Function


    Regards
    WTH

Posting Permissions

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