Access交流中心

北京 | 上海 | 天津 | 重庆 | 广州 | 深圳 | 珠海 | 汕头 | 佛山 | 中山 | 东莞 | 南京 | 苏州 | 无锡 | 常州 | 南通 | 扬州 | 徐州 | 杭州 | 温州 | 宁波 | 台州 | 福州 | 厦门 | 泉州 | 龙岩 | 合肥 | 芜湖 | 成都 | 遂宁 | 长沙 | 株洲 | 湘潭 | 武汉 | 南昌 | 济南 | 青岛 | 烟台 | 潍坊 | 淄博 | 济宁 | 太原 | 郑州 | 石家庄 | 保定 | 唐山 | 西安 | 大连 | 沈阳 | 长春 | 昆明 | 兰州 | 哈尔滨 | 佳木斯 | 南宁 | 桂林 | 海口 | 贵阳 | 西宁 | 乌鲁木齐 | 包头 |

窗体更新后的数据怎么赋给报表

杨乐  发表于:2018-06-22 08:28:57  
复制

查询出来的数据,在打印预览里显示的还是“查询”上的原始数据

Option Compare Database
Option Explicit
Private mclsQuery As GeneralQuery
Private Sub btnExport_Click()
 If Not Me.CX.Form.CurrentRecord > 0 Then Exit Sub
    ExportToExcel DataForm:=Me.CX
End Sub


Private Sub btnPrint_Click()
Me.PrintReport acViewNormal
End Sub


Private Sub btnPrintPreview_Click()
 Me.PrintReport acViewPreview
End Sub


Private Sub Command47_Click()
Dim rst As Object
Dim CSRQ As Date
Dim jsrq As Date
Dim strSQL As String
Me.Text40.Requery
Me.Text42.Requery
CSRQ = Form_HZCX.Text40
jsrq = Form_HZCX.Text42
strSQL = " SELECT '住院汇总' AS 减免类型 , COUNT ( ZYZFY ) AS 减免人次 , Round ( Sum ( ZYZFY ) , 2 ) AS 总费用 , Round ( Sum ( XNHBCJE ) , 2 ) AS 医保补偿费用 , Round ( Sum ( QTBCJE ) , 2 ) " & _
" AS 其它补偿费用 , Round ( Sum ( BCJMFY ) , 2 ) AS 减免费用 , Round ( Sum ( GRZFJE ) , 2 ) AS 个人自付费用 " & _
" FROM FYMX WHERE FYMX.HSSJ > # " & CSRQ & " # And FYMX.HSSJ < # " & jsrq & " # union SELECT '慢病汇总' AS 减免类型 , COUNT([MZZFY]) AS 减免人次 , Round ( Sum ( MZZFY ) , 2 ) " & _
" AS 总费用 , Round ( Sum ( XNHBCJE ) , 2 ) AS 医保补偿费用 , ( 0 ) AS 其它补偿费用 , Round ( Sum ( BCJMFY ) , 2 ) AS 减免费用 , " & _
" Round ( Sum ( GRZFJE ) , 2 ) AS 个人自付费用 FROM FPMBJM WHERE FPMBJM.HSSJ > # " & CSRQ & " # And FPMBJM.HSSJ < # " & jsrq & " # union " & _
" SELECT  '门诊汇总'  AS 减免类型 , COUNT([MZZFY]) AS 减免人次 , Round ( Sum ( MZZFY ) , 2 ) AS 总费用 , Round ( Sum ( XNHBCJE ) , 2 ) AS 医保补偿费用 , ( 0 ) AS 其它补偿费用 , " & _
" Round ( Sum ( BCJMFY ) , 2 ) AS 减免费用 , Round ( Sum ( GRZFJE ) , 2 ) AS 个人自付费用 FROM FPMZJM WHERE " & _
" FPMZJM.HSSJ > # " & CSRQ & " # And FPMZJM.HSSJ < # " & jsrq & " # "
Me.CX.Form.RecordSource = strSQL
Me.Refresh
End Sub




Private Sub Command53_Click()
Dim rst As Object
Dim CSRQ As Date
Dim jsrq As Date
Dim strSQL As String
Me.Text40.Requery
Me.Text42.Requery
CSRQ = Form_HZCX.Text40
jsrq = Form_HZCX.Text42
strSQL = " SELECT '扶贫住院汇总' AS 减免类型 , COUNT ( ZYZFY ) AS 减免人次 , Round ( Sum ( ZYZFY ) , 2 ) AS 总费用 , Round ( Sum ( XNHBCJE ) , 2 ) AS 医保补偿费用 , Round ( Sum ( QTBCJE ) , 2 ) " & _
" AS 其它补偿费用 , Round ( Sum ( BCJMFY ) , 2 ) AS 减免费用 , Round ( Sum ( GRZFJE ) , 2 ) AS 个人自付费用 " & _
" FROM FYMX WHERE FYMX.HSSJ > # " & CSRQ & " # And FYMX.HSSJ < # " & jsrq & " # union SELECT '扶贫慢病汇总' AS 减免类型 , COUNT([MZZFY]) AS 减免人次 , Round ( Sum ( MZZFY ) , 2 ) " & _
" AS 总费用 , Round ( Sum ( XNHBCJE ) , 2 ) AS 医保补偿费用 , ( 0 ) AS 其它补偿费用 , Round ( Sum ( BCJMFY ) , 2 ) AS 减免费用 , " & _
" Round ( Sum ( GRZFJE ) , 2 ) AS 个人自付费用 FROM FPMBJM WHERE FPMBJM.HSSJ > # " & CSRQ & " # And FPMBJM.HSSJ < # " & jsrq & " # union " & _
" SELECT  '扶贫门诊汇总'  AS 减免类型 , COUNT([MZZFY]) AS 减免人次 , Round ( Sum ( MZZFY ) , 2 ) AS 总费用 , Round ( Sum ( XNHBCJE ) , 2 ) AS 医保补偿费用 , ( 0 ) AS 其它补偿费用 , " & _
" Round ( Sum ( BCJMFY ) , 2 ) AS 减免费用 , Round ( Sum ( GRZFJE ) , 2 ) AS 个人自付费用 FROM FPMZJM WHERE " & _
" FPMZJM.HSSJ > # " & CSRQ & " # And FPMZJM.HSSJ < # " & jsrq & " # union SELECT ' 签约服务汇总 ' AS 减免类型 , COUNT ( ZYZFY ) AS 减免人次 , Round ( Sum ( ZYZFY ) , 2 ) AS 总费用 , " & _
" Round ( Sum ( NHBCFY ) , 2 ) AS 医保补偿费用 , Round ( Sum ( QTBCFY ) , 2 ) AS 其它补偿费用 , Round ( Sum ( QYJMFY ) " & _
" , 2 ) AS 减免费用 , Round ( Sum ( ZZZFFY ) , 2 ) AS 个人自付费用 FROM 表1 WHERE 表1.JMRQ > # " & CSRQ & " # And " & _
" 表1.JMRQ < # " & jsrq & " # UNION SELECT ' 民政优抚汇总 ' AS 减免类型 , COUNT ( ZYZFY ) AS 减免人次 , Round ( Sum " & _
" ( ZYZFY ) , 2 ) AS 总费用 , Round ( Sum ( YBBXFY ) , 2 ) AS 医保补偿费用 , Round ( Sum ( QTBCFY ) , 2 ) " & _
" AS 其它补偿费用 , Round ( Sum ( MZBCFY ) , 2 ) AS 减免费用 , Round ( Sum ( GRFDFY ) , 2 ) AS 个人自付费用 " & _
" FROM YFBX WHERE YFBX.BXRQ > # " & CSRQ & " # And YFBX.BXRQ < # " & jsrq & " # "
Me.CX.Form.RecordSource = strSQL
Me.Refresh
End Sub
Public Function PrintReport(View As AcView)
    On Error GoTo ErrorHandler


    Dim strWhere As String
    If Me.CX.Form.FilterOn Then
        strWhere = Replace(Me.CX.Form.Filter, "[" & Me.CX.Form.Name & "].", "")
    End If
    DoCmd.OpenReport "rptHZCX", View, , strWhere


ExitHere:
    Exit Function


ErrorHandler:
    Select Case Err.Number
    Case errOpenActionWasCanceled, errOperationCanceledByUser
    Case Else
        RDPErrorHandler Me.Name & ": Sub PrintReport()"
    End Select
End Function


 

Top
呵,年轻人 发表于:2018-06-22 13:55:31

将 点查询 以后的查询条件 或者 filter   打开报表的时候写上

名称 必选/可选 数据类型 说明
ReportName 必选 Variant 字符串表达式 (字符串表达式:任一求值为一列连续字符的表达式。表达式的元素可以是:返回字符串或字符串 Variant (VarType 8) 的函数;字符串字面值、常量、变量或 Variant。),表示当前数据库中的报表的有效名称。如果在某个类库数据库 (类库数据库:可以从任意应用程序中调用的过程和数据库对象的集合。为了使用库中的项,必须先建立从当前数据库到类库数据库的引用。)中执行包含 OpenReport 方法的 Visual Basic 代码,Microsoft Access 将首先在该类库数据库中查找具有此名称的报表,然后再到当前数据库中查找。
View 可选 AcView AcView 常量,指定报表将在哪个视图中打开。默认值为 acViewNormal
FilterName 可选 Variant 字符串表达式,表示当前数据库中的查询 (查询:有关表中所存储的数据的问题,或要对数据执行操作的请求。查询可以将多个表中的数据放在一起,以作为窗体或报表的数据源。)的有效名称。
WhereCondition 可选 Variant 字符串表达式,不包含 WHERE 关键字的有效 SQL WHERE 子句 (WHERE 子句:SQL 语句中用于指定哪部分记录被检索的语素。)
WindowMode 可选 AcWindowMode AcWindowMode 常量,指定窗体的打开模式。默认值为 acWindowNormal
OpenArgs 可选 Variant 设置 OpenArgs 属性。



总记录:1篇  页次:1/1 9 1 :