|
3#

楼主 |
发表于 2005-7-18 19:15:00
|
只看该作者
我用DSUM将止累的数值计算出来放在一个变量STR中,请问怎么将这个变量的值用到报表的控件上我是在报表打印窗体的"打印"控件中给STR赋值的Private Sub 预览_Click()
On Error GoTo Err_预览_Click Dim stDocName As String
Dim totalPeople As String
Dim totalCurreny As String
If Not IsNull(Me.输入年月) Then
totalPeople = CStr(Nz(DSum("[人次总计]", "旅游局月报查询", "month([日期按月]) <=" & Month(Me.输入年月) & " and (year(日期按月)=" & Year(Me.输入年月) & ")")))
totalCurreny = CStr(Nz(DSum("[金额总计]", "旅游局月报查询", "month([日期按月]) <=" & Month(Me.输入年月) & " and (year(日期按月)=" & Year(Me.输入年月) & ")")))
stDocName = "旅游局月报表"
DoCmd.OpenReport stDocName, acPreview
Reports![旅游局月报表]![人次止累] = totalPeople
Reports![旅游局月报表]![金额止累] = totalCurreny
Else
MsgBox "请输入年月"
Resume Exit_预览_Click
End If
Exit_预览_Click:
Exit SubErr_预览_Click:
MsgBox Err.Description
Resume Exit_预览_Click
End Sub报表打印出来,那两个控件值是空白,是不是要将这个两个变量设定为全局变量,然后在报表的事件代码中赋值? |
|