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
"rptTableOfGrades."
Here's the code I have so far:
Option Compare Database
Option Explicit
Private Sub PageHeaderSection_Format(Cancel 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.OpenRecordset("select * from qryTableOfGrades")
rst.MoveFirst
j = -1
i = 0
For i = 0 To rst.Fields.Count - 1
If rst.Fields(i).Name Like "*ID" Then GoTo skip_it
j = j + 1
Select Case j
Case 0
Me.Label0.Caption = rst.Fields(i).Name
Case 1
Me.Label1.Caption = rst.Fields(i).Name
Case 2
Me.Label2.Caption = rst.Fields(i).Name
Case 3
Me.Label3.Caption = rst.Fields(i).Name
Case 4
Me.Label4.Caption = rst.Fields(i).Name
Case 5
Me.Label5.Caption = rst.Fields(i).Name
Case 6
Me.Label6.Caption = rst.Fields(i).Name
Case 7
Me.Label7.Caption = rst.Fields(i).Name
Case 8
Me.Label8.Caption = rst.Fields(i).Name
Case 9
Me.Label9.Caption = rst.Fields(i).Name
Case 10
Me.Label10.Caption = rst.Fields(i).Name
Case 11
Me.Label11.Caption = rst.Fields(i).Name
Case 12
Me.Label12.Caption = rst.Fields(i).Name
End Select
skip_it:
Next
rst.Clone
Set rst = Nothing
End Sub
Private Sub Report_Open(Cancel 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.OpenRecordset("select * from qryTableOfGrades")
rst.MoveFirst
j = -1
i = 0
For i = 0 To rst.Fields.Count - 1
If rst.Fields(i).Name Like "*ID" Then GoTo skip_it
j = j + 1
Select Case j
Case 0
Me.field0.ControlSource = rst.Fields(i).Name
Case 1
Me.field1.ControlSource = rst.Fields(i).Name
Case 2
Me.field2.ControlSource = rst.Fields(i).Name
Case 3
Me.field3.ControlSource = rst.Fields(i).Name
Case 4
Me.field4.ControlSource = rst.Fields(i).Name
Case 5
Me.field5.ControlSource = rst.Fields(i).Name
Case 6
Me.field6.ControlSource = rst.Fields(i).Name
Case 7
Me.field7.ControlSource = rst.Fields(i).Name
Case 8
Me.field8.ControlSource = rst.Fields(i).Name
Case 9
Me.field9.ControlSource = rst.Fields(i).Name
Case 10
Me.field10.ControlSource = rst.Fields(i).Name
Case 11
Me.field11.ControlSource = rst.Fields(i).Name
Case 12
Me.field12.ControlSource = rst.Fields(i).Name
End Select
skip_it:
Next i
rst.Close
Set rst = Nothing
End Sub