北京 | 上海 | 天津 | 重庆 | 广州 | 深圳 | 珠海 | 汕头 | 佛山 | 中山 | 东莞 | 南京 | 苏州 | 无锡 | 常州 | 南通 | 扬州 | 徐州 | 杭州 | 温州 | 宁波 | 台州 | 福州 | 厦门 | 泉州 | 龙岩 | 合肥 | 芜湖 | 成都 | 遂宁 | 长沙 | 株洲 | 湘潭 | 武汉 | 南昌 | 济南 | 青岛 | 烟台 | 潍坊 | 淄博 | 济宁 | 太原 | 郑州 | 石家庄 | 保定 | 唐山 | 西安 | 大连 | 沈阳 | 长春 | 昆明 | 兰州 | 哈尔滨 | 佳木斯 | 南宁 | 桂林 | 海口 | 贵阳 | 西宁 | 乌鲁木齐 | 包头 |
请问为何主体段中会出现空白行,如何去除?见图片注解,谢谢坛友
附使用的何勇老师的主体段固定行打印程序,
报表打开事件:
Private Sub Report_Open(Cancel As Integer)
''打开初始化值
LngAllRecords = 0
IntPageCount = 0
LngSectionCount = 0
End Sub
报表主体格式程序:
Private Sub 主体_Format(Cancel As Integer, FormatCount As Integer)
SetDetailFormat Me, Txt总计数, 11, 0
End Sub
SetDetailFormat 模块:
Option Compare Database
Option Explicit
'Private Const intCountPerPage = 20 ''是指定的每页打印记录行数
Public LngAllRecords As Long ''统计节全部记录数
Public IntPageCount As Integer ''页计数
Public LngSectionCount As Long ''节计数
Public Sub SetDetailFormat(ByVal TheReport As Report, ByVal CountAllRows As Integer, Optional intCountPerPage As Integer, Optional SectionSurplusRows As Integer = 0)
'===============================================================================
'-函数名称: SelectDetailFormat
'-功能描述: 设置报表的不足补空行报表
'-输入参数说明: 参数1:TheReport 报表,输入me
' 参数2:CountAllRows 统计所有的行
' 请在报表上增加一个字段(例FieldsA),行来源为"=Count(*),可见性为否
' 参数3:intCountPerPage 每页的行数
' 参数4:SectionSurplusRows 分组剩余行给签名备注栏
'-返回参数说明: 无
'-使用语法示例: SetDetailFormat me,me.FieldsA,20
'-参考:
'-使用注意: 请在报表的Report_Open事件中输入:TempRows=0 '初始化
'-兼容性: 2000,XP已测试
'-作者: 何勇, Email:Cuxun@qq.com ,QQ:100810401
'-更新日期: 2007-9-21
'===============================================================================
On Error GoTo Err:
'当有页面汇总时在页面页脚下相应减去节计数
'LngSectionCount = LngSectionCount - 1
LngAllRecords = LngAllRecords + 1 ''全部的记录计数
IntPageCount = IntPageCount + 1 ''页计数
LngSectionCount = LngSectionCount + 1 ''节计数
''当每节的数据大于最大的数据,并且当页的行数小于每页最低行数时新加空白行
If LngSectionCount >= CountAllRows And IntPageCount < intCountPerPage - SectionSurplusRows Then
TheReport.NextRecord = False
End If
''当页包含空行的数据等于最低行数时判断
If IntPageCount Mod intCountPerPage = 0 Then
''分页
TheReport.Section(0).ForceNewPage = 1
Else
''不分页
TheReport.Section(0).ForceNewPage = 0
End If
''把前面的空行内的数据隐藏成白色
If IntPageCount > CountAllRows Or LngSectionCount > CountAllRows Then
showHideCtrlAtDetail TheReport, False
Else
showHideCtrlAtDetail TheReport, True
End If
Err:
''不显示出错提示
' If Err.Number <> 0 Then MsgBox Err.Description
Exit Sub
End Sub
Private Sub showHideCtrlAtDetail(ByVal TheReport As Report, ByVal isShow As Boolean)
Dim Ctr1 As Control
''只针对主体页
For Each Ctr1 In TheReport.Section(acDetail).Controls
If isShow = False Then
Ctr1.ForeColor = 16777215
Else
Ctr1.ForeColor = 0
End If
Next
End Sub