设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

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

[报表] 报表预览和打印的数据不一致

[复制链接]
跳转到指定楼层
1#
发表于 2013-1-11 13:11:50 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 VulcanTerry 于 2013-1-11 14:18 编辑

       应用中设计的统计报表,由于要汇总的数据需要引用其他表的字段值,于是参考论坛中“分页合计”的方法,汇总数据不是字段的合计"sum(字段)",而是VBA代码生成的汇总数据。报表数据在预览中显示正确,但通过预览右键菜单打印的报表,得到的数据会比正确数据大一倍。

        附件中,打印报表的窗体名是“frmProductMain”,通过预览后,打印或导出PDF文件,最后的总计数量都会翻一倍,冏。

        报表的VBA代码如下:
Option Compare Database
Option Explicit

Private curTotalBal, curTotalIn, curTotalOut, curTotalInv, curSumBal, curSumIn, curSumOut, curSumInv As Currency

Private Sub Report_Open(Cancel As Integer)
    Me.Caption = dtmStartDate & "至" & dtmEndDate & "商品库存表"
End Sub

Private Sub 报表页脚_Print(Cancel As Integer, PrintCount As Integer)
    Me.txtTotalBal = curTotalBal
    Me.txtTotalIn = curTotalIn
    Me.txtTotalOut = curTotalOut
    Me.txtTotalInv = curTotalInv
End Sub

Private Sub 报表页眉_Print(Cancel As Integer, PrintCount As Integer)
    curTotalBal = 0
    curTotalIn = 0
    curTotalOut = 0
    curTotalInv = 0
End Sub

Private Sub 主体_Print(Cancel As Integer, PrintCount As Integer)
    curSumBal = curSumBal + Me.txtBal
    curSumIn = curSumIn + Me.txtIn
    curSumOut = curSumOut + Me.txtOut
    curSumInv = curSumInv + Me.txtInv
End Sub

Private Sub 组页脚0_Print(Cancel As Integer, PrintCount As Integer)
    Me.txtSumBal = curSumBal
    Me.txtSumIn = curSumIn
    Me.txtSumOut = curSumOut
    Me.txtSumInv = curSumInv
    curTotalBal = curTotalBal + Me.txtSumBal
    curTotalIn = curTotalIn + Me.txtSumIn
    curTotalOut = curTotalOut + Me.txtSumOut
    curTotalInv = curTotalInv + Me.txtSumInv
End Sub

Private Sub 组页眉0_Print(Cancel As Integer, PrintCount As Integer)
    curSumBal = 0
    curSumIn = 0
    curSumOut = 0
    curSumInv = 0
End Sub

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖 订阅订阅
2#
发表于 2013-1-11 14:04:59 | 只看该作者
用Dsum求和不就完事了
3#
 楼主| 发表于 2013-1-11 14:13:51 | 只看该作者
todaynew 发表于 2013-1-11 14:04
用Dsum求和不就完事了

呵呵,谢谢支持
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-4-29 15:45 , Processed in 0.086436 second(s), 27 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

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