Hi Experts,
I am trying to create a report using code and have it begin a new page after printing out 15 records. It appears the system can not move to a new page unless the size of the section or group is larger than the page. When this happens it does not format properly. Is there a way to force the reords into groups of 15 to then using the force new page command?
Has anyone ever done anything like this or know how this can be done?
Regards,
Callum
Option Compare Database
Private Sub GroupFooter1_Format(Cancel As Integer, FormatCount As Integer)
End Sub
Private Sub GroupHeader0_Format(Cancel As Integer, FormatCount As Integer)
MonthlyShipmentsSQL = "SELECT * from SalesOrderLines"
MonthlyInkTotalSQL = "select * from MonthlyInkTotals where companyid = 'BER05' and ProcessEndDate = #1/15/05#"
Set curDatabase = Application.CurrentProject.connection
Dim MonthlyInkTotalRS As New ADODB.Recordset
Dim MonthlyShipmentsRS As New ADODB.Recordset
Dim OrderLinesRS As New ADODB.Recordset
MonthlyInkTotalRS.Open MonthlyInkTotalSQL, curDatabase, adOpenStatic
Me.GroupHeader0.Height = 4500
MsgBox MonthlyInkTotalRS.RecordCount
For J = 1 To MonthlyInkTotalRS.RecordCount
If J > 1 Then
Me.CurrentY = Me.CurrentY + 560
End If
Me.CurrentX = 5
Print MonthlyInkTotalRS!InkCode
CurrentY = CurrentY - 180
CurrentX = 1350
Print "DESCRIP"
CurrentY = CurrentY - 180
CurrentX = 2300
Print MonthlyInkTotalRS!PreviousTotal
OrderLinesSQL = "SELECT SalesOrderLines.SalesOrderLineNum, SalesOrderLines.SalesOrderID, SalesOrderLines.InkCode, SalesOrderLines.Amount, SalesOrderLines.Price, SalesOrders.CompanyID, SalesOrders.SalesOrderDate" & _
" FROM SalesOrderLines INNER JOIN SalesOrders ON SalesOrderLines.SalesOrderID = SalesOrders.SalesOrderID " & _
" WHERE (((SalesOrders.CompanyID)='ber05') AND ((SalesOrders.SalesOrderDate) Between #12/15/2004# And #02/15/2005#)) and SalesOrderLines.inkcode = '" & MonthlyInkTotalRS!InkCode & "'"
OrderLinesRS.Open OrderLinesSQL, curDatabase, adOpenStatic
If OrderLinesRS.RecordCount > 0 Then
Me.CurrentX = 3000
X = 3000
Y = Me.CurrentY - 180
For I = 1 To OrderLinesRS.RecordCount
Z = X + ((I - 1) * 800)
CurrentY = Y
Me.CurrentX = Z
Print OrderLinesRS!Amount
Me.CurrentX = Z
Print OrderLinesRS!SalesOrderID
Me.CurrentX = Z
Print OrderLinesRS!SalesOrderDate
OrderLinesRS.MoveNext
CurrentY = Y
rowcount = rowcount + 1
Next
End If
OrderLinesRS.Close
CurrentY = Y
CurrentX = 6250
Print MonthlyInkTotalRS!ShipedTotal & MonthlyInkTotalRS!PreviousTotal
CurrentY = Y
CurrentX = 7600
Print MonthlyInkTotalRS!AmountRemaining
MonthlyInkTotalRS.MoveNext
If rowcount >= 10 Then
' MainReport.ForceNewPage
' Me.GroupHeader0.ForceNewPage
End If
Next
End Sub
Private Sub MainReport_Format(Cancel As Integer, FormatCount As Integer)
End Sub
Private Sub Report_Open(Cancel As Integer)
End Sub
I am trying to create a report using code and have it begin a new page after printing out 15 records. It appears the system can not move to a new page unless the size of the section or group is larger than the page. When this happens it does not format properly. Is there a way to force the reords into groups of 15 to then using the force new page command?
Has anyone ever done anything like this or know how this can be done?
Regards,
Callum
Option Compare Database
Private Sub GroupFooter1_Format(Cancel As Integer, FormatCount As Integer)
End Sub
Private Sub GroupHeader0_Format(Cancel As Integer, FormatCount As Integer)
MonthlyShipmentsSQL = "SELECT * from SalesOrderLines"
MonthlyInkTotalSQL = "select * from MonthlyInkTotals where companyid = 'BER05' and ProcessEndDate = #1/15/05#"
Set curDatabase = Application.CurrentProject.connection
Dim MonthlyInkTotalRS As New ADODB.Recordset
Dim MonthlyShipmentsRS As New ADODB.Recordset
Dim OrderLinesRS As New ADODB.Recordset
MonthlyInkTotalRS.Open MonthlyInkTotalSQL, curDatabase, adOpenStatic
Me.GroupHeader0.Height = 4500
MsgBox MonthlyInkTotalRS.RecordCount
For J = 1 To MonthlyInkTotalRS.RecordCount
If J > 1 Then
Me.CurrentY = Me.CurrentY + 560
End If
Me.CurrentX = 5
Print MonthlyInkTotalRS!InkCode
CurrentY = CurrentY - 180
CurrentX = 1350
Print "DESCRIP"
CurrentY = CurrentY - 180
CurrentX = 2300
Print MonthlyInkTotalRS!PreviousTotal
OrderLinesSQL = "SELECT SalesOrderLines.SalesOrderLineNum, SalesOrderLines.SalesOrderID, SalesOrderLines.InkCode, SalesOrderLines.Amount, SalesOrderLines.Price, SalesOrders.CompanyID, SalesOrders.SalesOrderDate" & _
" FROM SalesOrderLines INNER JOIN SalesOrders ON SalesOrderLines.SalesOrderID = SalesOrders.SalesOrderID " & _
" WHERE (((SalesOrders.CompanyID)='ber05') AND ((SalesOrders.SalesOrderDate) Between #12/15/2004# And #02/15/2005#)) and SalesOrderLines.inkcode = '" & MonthlyInkTotalRS!InkCode & "'"
OrderLinesRS.Open OrderLinesSQL, curDatabase, adOpenStatic
If OrderLinesRS.RecordCount > 0 Then
Me.CurrentX = 3000
X = 3000
Y = Me.CurrentY - 180
For I = 1 To OrderLinesRS.RecordCount
Z = X + ((I - 1) * 800)
CurrentY = Y
Me.CurrentX = Z
Print OrderLinesRS!Amount
Me.CurrentX = Z
Print OrderLinesRS!SalesOrderID
Me.CurrentX = Z
Print OrderLinesRS!SalesOrderDate
OrderLinesRS.MoveNext
CurrentY = Y
rowcount = rowcount + 1
Next
End If
OrderLinesRS.Close
CurrentY = Y
CurrentX = 6250
Print MonthlyInkTotalRS!ShipedTotal & MonthlyInkTotalRS!PreviousTotal
CurrentY = Y
CurrentX = 7600
Print MonthlyInkTotalRS!AmountRemaining
MonthlyInkTotalRS.MoveNext
If rowcount >= 10 Then
' MainReport.ForceNewPage
' Me.GroupHeader0.ForceNewPage
End If
Next
End Sub
Private Sub MainReport_Format(Cancel As Integer, FormatCount As Integer)
End Sub
Private Sub Report_Open(Cancel As Integer)
End Sub