北京 | 上海 | 天津 | 重庆 | 广州 | 深圳 | 珠海 | 汕头 | 佛山 | 中山 | 东莞 | 南京 | 苏州 | 无锡 | 常州 | 南通 | 扬州 | 徐州 | 杭州 | 温州 | 宁波 | 台州 | 福州 | 厦门 | 泉州 | 龙岩 | 合肥 | 芜湖 | 成都 | 遂宁 | 长沙 | 株洲 | 湘潭 | 武汉 | 南昌 | 济南 | 青岛 | 烟台 | 潍坊 | 淄博 | 济宁 | 太原 | 郑州 | 石家庄 | 保定 | 唐山 | 西安 | 大连 | 沈阳 | 长春 | 昆明 | 兰州 | 哈尔滨 | 佳木斯 | 南宁 | 桂林 | 海口 | 贵阳 | 西宁 | 乌鲁木齐 | 包头 |
' 函数名:RepDetail_Format()
' 调用报表必须使用控件:(文本框)
' txtRecord_NO 在主体节 可见 用于显示记录号,可选
' txtTotGrp 在主体节 不可见 =Count(*) 用于取得报表的总记录数,必须
' txtCurrentPage 在主体节 不可见 =[Page] 用于取得当前页数,必须
'
' 参数说明: RepName 报表名称 (当前报表可用 (Me), 其它报表可用:(Reports.报表名)引用)
' txtCurrentPage 报表主体节上的[txtCurrentPage]文本框控件
' txtRecordNum 报表定义的私人变量 用于记录数的递增,必须 使用直接用:txtRecordNum 输入不可变更
' (注:Private txtRecordNum As Integer)
' txtTotGrp 报表主体节上的[txtTotGrp]文本框控件
' IntPrintLen 报表打印的行数。 数据类型:Integer (注:不可超过每页允许的最大记录数)
'
' 使用方法:
' 1,先定义一私人变量:Private txtRecordNum As Integer,必须
' 2,报表主体节的格式化事件中调用(Detail_Format 事件)
' 调用方法:NextRecord=RepDetail_Format(RepName , txtCurrentPage.text , txtRecordNum , txtTotGrp.text , IntPrintLen)
' 使用示例:NextRecord = RepDetail_Format(Me, [txtCurrentPage], txtRecordNum, [txtTotGrp], 20)
'==============================================================
Option Compare Database
Option Explicit '不允许使用未经声明的变量,可以防止引用错误的变量
Function RepDetail_Format(RepName As Report, txtCurrentPage As Integer, txtRecordNum As Integer, txtTotGrp As String, IntPrintLen As Integer) As Boolean
Dim ctrl As Control '定义ctrl为控件数据类型
Dim intCurrentPage1stI As Integer 'intCurrentPage1stI记录每页起始的I,用于强制分页
Dim intMaxI As Integer 'intMaxI是用计算得出的所有页的总行数(包括空行)
Dim intCountPerPage As Integer 'intCountPerPage是指定的每页打印记录行数
On Error GoTo ER
intCountPerPage = IntPrintLen 'intCountPerPage是指定的每页打印记录行数
'----------------------------------------
txtRecordNum = txtRecordNum + 1 '----递增全局 txtRecordNum 变量
'--------------计算最大记录数--------------------
If intMaxI = 0 Then
If txtTotGrp Mod intCountPerPage = 0 Then
intMaxI = txtTotGrp
Else
intMaxI = (Fix(txtTotGrp / intCountPerPage) + 1) * intCountPerPage
End If
End If
'-----------------------------------------------
'设置每页第一条记录的记录数(顺号值)
' If txtRecordNum = IntPrintLen Then intCurrentPage1stI = (txtCurrentPage - 1) * intCountPerPage
intCurrentPage1stI = (txtCurrentPage - 1) * intCountPerPage
' Debug.Print "intCurrentPage1stI=" & intCurrentPage1stI & " intCountPerPage + intCurrentPage1stI=" & intCountPerPage + intCurrentPage1stI & " intMaxI=" & intMaxI
'当到达本页设定的记录数时,强制分页
If txtRecordNum = intCountPerPage + intCurrentPage1stI Then
RepName.Section(acDetail).ForceNewPage = 1
Else
RepName.Section(acDetail).ForceNewPage = 0
End If
If txtRecordNum <= txtTotGrp Then
' If txtRecordNum = 0 Then txtRecordNum = 1
For Each ctrl In RepName.Section(0).Controls
' Debug.Print "ctrl.ItemData" & ctrl.ItemData
With ctrl
.ForeColor = 0
End With
Next ctrl