设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

返回列表 发新帖
查看: 1743|回复: 3
打印 上一主题 下一主题

[报表] 如何依据数据手动来对报表进行添加空行

[复制链接]
1#
发表于 2012-7-11 17:23:48 | 显示全部楼层
好像是t小宝的作品……请自行创建模块处理。
  1. Option Compare Database
  2. Option Explicit

  3. '************************************************************************************************
  4. '参数说明:
  5. 'ReportSheet (rpt, LeftControl, RightControl, RowsOfPage, Style)
  6. '           rpt:必选,报表名称
  7. '           LeftControl:必选,最左边控件名称,用于确定左边距。
  8. '           RightControl:必选,最右边控件名称,用于确定右边距。
  9. '           RowsOfPage:可选,为每页指定行数
  10. '           Style:可选,0为方框,1为仅画横线,2为仅画竖线。
  11. '调用说明:
  12. '在报表中“打印页前”事件中调用:=ReportSheet (rpt, [左控件名称], [右控件名称], RowsOfPage, Style)
  13. '*************************************************************************************************
  14. Public Function ReportSheet(rpt As Report, LeftControl As Control, RightControl As Control, _
  15.                             Optional RowsOfPage As Integer, Optional Style As Integer = 0)
  16. On Error Resume Next

  17.     Dim intI As Integer
  18.     Dim lngTop As Long
  19.     Dim lngBottom As Long
  20.     Dim lngLeft As Long
  21.     Dim lngRight As Long
  22.     Dim lngRowHeight As Long
  23.    
  24.     Dim lngRows As Long
  25.     Dim lngRowTop As Long
  26.     Dim lngBottomMax As Long
  27.    
  28.     Dim ctl As Control
  29.    
  30.     With rpt
  31.         lngRowHeight = .Section(acDetail).Height
  32.         lngTop = .Section(acPageHeader).Height
  33.         If .Page = 1 Then lngTop = lngTop + .Section(acHeader).Height
  34.         lngBottomMax = .Section(acPageFooter).Height
  35.         lngBottomMax = .ScaleHeight - lngBottomMax
  36.     End With

  37.     lngRows = Int((lngBottomMax - lngTop) / lngRowHeight)
  38.     If RowsOfPage > 0 Then
  39.        If RowsOfPage < lngRows Then lngRows = RowsOfPage
  40.     End If
  41.     lngBottom = lngTop + lngRowHeight * lngRows
  42.    
  43.     lngLeft = rpt.ScaleWidth
  44.     For Each ctl In rpt.Section(acDetail).Controls
  45.         If lngLeft > ctl.Left Then lngLeft = ctl.Left
  46.         If lngRight < ctl.Left + ctl.Width Then lngRight = ctl.Left + ctl.Width
  47.         If Style <> 1 Then rpt.Line (ctl.Left, lngTop)-(ctl.Left, lngBottom)
  48.     Next
  49.     If Style <> 1 Then rpt.Line (lngRight, lngTop)-(lngRight, lngBottom)
  50.    
  51.    
  52.     If Style <> 2 Then
  53.         For intI = 0 To lngRows
  54.             rpt.Line (lngLeft, lngTop + lngRowHeight * intI)-(lngRight, lngTop + lngRowHeight * intI)
  55.             
  56.         Next
  57.     End If
  58.         
  59. End Function
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-5-22 22:58 , Processed in 0.104393 second(s), 24 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表