Printing report programatically while the report is still processing

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Richard Hollenbeck

    Printing report programatically while the report is still processing

    I have a report that is dynamically naming the columns and rows, etc., but I
    have way more columns (at least 37 at this time) than will fit on the report
    comfortably. So I have ten columns on the report (field3 through field12
    and label3 through label12). I want to loop through the next 10 columns on
    a new page. I thought I would insert a print command after label12 is
    populated then make field3 thru field12 take the next ten columns and print
    another page until the entire list of columns is complete. I tried me.print
    and docmd.printout but I got errors. What is the proper way to get the
    currently processed page to print before continuing? The report is called
    "rptTableOfGrad es."

    Here's the code I have so far:

    Option Compare Database
    Option Explicit

    Private Sub PageHeaderSecti on_Format(Cance l As Integer, FormatCount As
    Integer)
    Dim rst As DAO.Recordset
    Dim db As DAO.Database
    Dim i As Integer
    Dim j As Integer

    Set db = CurrentDb
    Set rst = db.OpenRecordse t("select * from qryTableOfGrade s")

    rst.MoveFirst
    j = -1
    i = 0

    For i = 0 To rst.Fields.Coun t - 1
    If rst.Fields(i).N ame Like "*ID" Then GoTo skip_it
    j = j + 1

    Select Case j
    Case 0
    Me.Label0.Capti on = rst.Fields(i).N ame
    Case 1
    Me.Label1.Capti on = rst.Fields(i).N ame
    Case 2
    Me.Label2.Capti on = rst.Fields(i).N ame
    Case 3
    Me.Label3.Capti on = rst.Fields(i).N ame
    Case 4
    Me.Label4.Capti on = rst.Fields(i).N ame
    Case 5
    Me.Label5.Capti on = rst.Fields(i).N ame
    Case 6
    Me.Label6.Capti on = rst.Fields(i).N ame
    Case 7
    Me.Label7.Capti on = rst.Fields(i).N ame
    Case 8
    Me.Label8.Capti on = rst.Fields(i).N ame
    Case 9
    Me.Label9.Capti on = rst.Fields(i).N ame
    Case 10
    Me.Label10.Capt ion = rst.Fields(i).N ame
    Case 11
    Me.Label11.Capt ion = rst.Fields(i).N ame
    Case 12
    Me.Label12.Capt ion = rst.Fields(i).N ame
    End Select

    skip_it:
    Next
    rst.Clone
    Set rst = Nothing
    End Sub


    Private Sub Report_Open(Can cel As Integer)
    Dim rst As DAO.Recordset
    Dim db As DAO.Database
    Dim i As Integer
    Dim j As Integer
    Set db = CurrentDb
    Set rst = db.OpenRecordse t("select * from qryTableOfGrade s")
    rst.MoveFirst

    j = -1
    i = 0

    For i = 0 To rst.Fields.Coun t - 1
    If rst.Fields(i).N ame Like "*ID" Then GoTo skip_it
    j = j + 1
    Select Case j
    Case 0
    Me.field0.Contr olSource = rst.Fields(i).N ame
    Case 1
    Me.field1.Contr olSource = rst.Fields(i).N ame
    Case 2
    Me.field2.Contr olSource = rst.Fields(i).N ame
    Case 3
    Me.field3.Contr olSource = rst.Fields(i).N ame
    Case 4
    Me.field4.Contr olSource = rst.Fields(i).N ame
    Case 5
    Me.field5.Contr olSource = rst.Fields(i).N ame
    Case 6
    Me.field6.Contr olSource = rst.Fields(i).N ame
    Case 7
    Me.field7.Contr olSource = rst.Fields(i).N ame
    Case 8
    Me.field8.Contr olSource = rst.Fields(i).N ame
    Case 9
    Me.field9.Contr olSource = rst.Fields(i).N ame
    Case 10
    Me.field10.Cont rolSource = rst.Fields(i).N ame
    Case 11
    Me.field11.Cont rolSource = rst.Fields(i).N ame
    Case 12
    Me.field12.Cont rolSource = rst.Fields(i).N ame
    End Select

    skip_it:
    Next i
    rst.Close
    Set rst = Nothing
    End Sub


  • Richard Hollenbeck

    #2
    Re: Printing report programatically while the report is still processing

    It wasn't necessary. I made a global variable, n, hooked to an input box
    asking for a starting column. Now the user can select eleven as the
    starting column and print 11-20, 21-30, etc. with the same form. So, in the
    case statement, I changed it from:

    "case 3"
    "case 4"
    "case 5" etc., to:

    "case n" ' "n" already equals n + 2 (because the first and second field are
    not columns.)
    "case n + 1"
    "case n + 2"

    etc.

    Works great!


    "Richard Hollenbeck" <richard.hollen beck@verizon.ne t> wrote in message
    news:x5yQc.570$ 721.384@nwrddc0 3.gnilink.net.. .[color=blue]
    > I have a report that is dynamically naming the columns and rows, etc., but[/color]
    I[color=blue]
    > have way more columns (at least 37 at this time) than will fit on the[/color]
    report[color=blue]
    > comfortably. So I have ten columns on the report (field3 through field12
    > and label3 through label12). I want to loop through the next 10 columns[/color]
    on[color=blue]
    > a new page. I thought I would insert a print command after label12 is
    > populated then make field3 thru field12 take the next ten columns and[/color]
    print[color=blue]
    > another page until the entire list of columns is complete. I tried[/color]
    me.print[color=blue]
    > and docmd.printout but I got errors. What is the proper way to get the
    > currently processed page to print before continuing? The report is called
    > "rptTableOfGrad es."
    >
    > Here's the code I have so far:
    >
    > Option Compare Database
    > Option Explicit
    >
    > Private Sub PageHeaderSecti on_Format(Cance l As Integer, FormatCount As
    > Integer)
    > Dim rst As DAO.Recordset
    > Dim db As DAO.Database
    > Dim i As Integer
    > Dim j As Integer
    >
    > Set db = CurrentDb
    > Set rst = db.OpenRecordse t("select * from qryTableOfGrade s")
    >
    > rst.MoveFirst
    > j = -1
    > i = 0
    >
    > For i = 0 To rst.Fields.Coun t - 1
    > If rst.Fields(i).N ame Like "*ID" Then GoTo skip_it
    > j = j + 1
    >
    > Select Case j
    > Case 0
    > Me.Label0.Capti on = rst.Fields(i).N ame
    > Case 1
    > Me.Label1.Capti on = rst.Fields(i).N ame
    > Case 2
    > Me.Label2.Capti on = rst.Fields(i).N ame
    > Case 3
    > Me.Label3.Capti on = rst.Fields(i).N ame
    > Case 4
    > Me.Label4.Capti on = rst.Fields(i).N ame
    > Case 5
    > Me.Label5.Capti on = rst.Fields(i).N ame
    > Case 6
    > Me.Label6.Capti on = rst.Fields(i).N ame
    > Case 7
    > Me.Label7.Capti on = rst.Fields(i).N ame
    > Case 8
    > Me.Label8.Capti on = rst.Fields(i).N ame
    > Case 9
    > Me.Label9.Capti on = rst.Fields(i).N ame
    > Case 10
    > Me.Label10.Capt ion = rst.Fields(i).N ame
    > Case 11
    > Me.Label11.Capt ion = rst.Fields(i).N ame
    > Case 12
    > Me.Label12.Capt ion = rst.Fields(i).N ame
    > End Select
    >
    > skip_it:
    > Next
    > rst.Clone
    > Set rst = Nothing
    > End Sub
    >
    >
    > Private Sub Report_Open(Can cel As Integer)
    > Dim rst As DAO.Recordset
    > Dim db As DAO.Database
    > Dim i As Integer
    > Dim j As Integer
    > Set db = CurrentDb
    > Set rst = db.OpenRecordse t("select * from qryTableOfGrade s")
    > rst.MoveFirst
    >
    > j = -1
    > i = 0
    >
    > For i = 0 To rst.Fields.Coun t - 1
    > If rst.Fields(i).N ame Like "*ID" Then GoTo skip_it
    > j = j + 1
    > Select Case j
    > Case 0
    > Me.field0.Contr olSource = rst.Fields(i).N ame
    > Case 1
    > Me.field1.Contr olSource = rst.Fields(i).N ame
    > Case 2
    > Me.field2.Contr olSource = rst.Fields(i).N ame
    > Case 3
    > Me.field3.Contr olSource = rst.Fields(i).N ame
    > Case 4
    > Me.field4.Contr olSource = rst.Fields(i).N ame
    > Case 5
    > Me.field5.Contr olSource = rst.Fields(i).N ame
    > Case 6
    > Me.field6.Contr olSource = rst.Fields(i).N ame
    > Case 7
    > Me.field7.Contr olSource = rst.Fields(i).N ame
    > Case 8
    > Me.field8.Contr olSource = rst.Fields(i).N ame
    > Case 9
    > Me.field9.Contr olSource = rst.Fields(i).N ame
    > Case 10
    > Me.field10.Cont rolSource = rst.Fields(i).N ame
    > Case 11
    > Me.field11.Cont rolSource = rst.Fields(i).N ame
    > Case 12
    > Me.field12.Cont rolSource = rst.Fields(i).N ame
    > End Select
    >
    > skip_it:
    > Next i
    > rst.Close
    > Set rst = Nothing
    > End Sub
    >
    >[/color]


    Comment

    Working...