标题: 关于分页合计的问题(已解决如果表内值为空,生产错误问题,请看15楼) [打印本页] 作者: ly_19811105 时间: 2007-8-7 13:09 标题: 关于分页合计的问题(已解决如果表内值为空,生产错误问题,请看15楼) Dim mysum1 As Double
Dim mysum2 As Double
Dim xx
Private Sub Report_Open(Cancel As Integer)
End Sub
Private Sub 页面页脚_Format(Cancel As Integer, FormatCount As Integer)
Text21.Value = "本页共计: " & mysum2 & "cone"
Text23.Value = "本页共计: " & mysum1 & "个ITEM"
mysum2 = 0
mysum1 = 0
End Sub
Private Sub 主体_Format(Cancel As Integer, FormatCount As Integer)
End Sub
Private Sub 主体_Print(Cancel As Integer, PrintCount As Integer)
If IsNull(执货数量) Then
mysum1 = mysum1 + 1
mysum2 = mysum2 + 执货数量.Value
Else
mysum2 = 0
mysum1 = 0
End If
End Sub
[ 本帖最后由 ly_19811105 于 2007-8-11 20:47 编辑 ]作者: ly_19811105 时间: 2007-8-7 14:19
不要沉啊,还没有人解决呢???作者: 一点通 时间: 2007-8-7 14:30
更改为iserror()函数试下作者: ly_19811105 时间: 2007-8-7 14:50
Dim mysum1 As Double
Dim mysum2 As Double
Dim xx
Private Sub Report_Open(Cancel As Integer)
End Sub
Private Sub 页面页脚_Format(Cancel As Integer, FormatCount As Integer)
Text21.Value = "本页共计: " & mysum2 & "cone"
Text23.Value = "本页共计: " & mysum1 & "个ITEM"
mysum2 = 0
mysum1 = 0
End Sub
Private Sub 主体_Format(Cancel As Integer, FormatCount As Integer)
End Sub
Private Sub 主体_Print(Cancel As Integer, PrintCount As Integer)
If IsNull(执货数量) Then
mysum1 = mysum1 + 1
if iserror(mysum2 = mysum2 + 执货数量.Value)=ture then
mysum2=0
end if
Else
mysum2 = 0
mysum1 = 0
End If
End Sub
如果报表无数据,您需要在报表的“无数据”事件中:Private Sub Report_NoData(Cancel As Integer)设置代码,而不是在页合计中设置。作者: ly_19811105 时间: 2007-8-11 14:12
多谢版主,因为是菜鸟,对Access的VBA不了解,所以一直都没有办法做到,现在已经解决了。多谢!!!
Option Compare Database
Dim mysum1 As Double
Dim mysum2 As Double
Dim x As Boolean
Private Sub Report_NoData(Cancel As Integer)
x = False
End Sub
Private Sub Report_Open(Cancel As Integer)
End Sub
Private Sub 页面页脚_Format(Cancel As Integer, FormatCount As Integer)
End Sub
Private Sub 页面页脚_Print(Cancel As Integer, PrintCount As Integer)
Text23.Value = "本页共计: " & mysum1 & " CONE"
Text24.Value = "本页共计: " & mysum2 & " 个ITEM"
mysum1 = 0
mysum2 = 0
End Sub
Private Sub 主体_Format(Cancel As Integer, FormatCount As Integer)
End Sub
Private Sub 主体_Print(Cancel As Integer, PrintCount As Integer)
If x = True Then
mysum1 = mysum1 + 执货数量.Value
mysum2 = mysum2 + 1
Else
mysum1 = 0
mysum2 = 0
End If
End Sub
把我的代码贴出来让你帮忙看看有没有问题,没有问题也能让像我一样的菜鸟共享一下