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
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
Comment