Office中国论坛/Access中国论坛

标题: 如何实现“将窗体中通过系统自带筛选得到的结果记录进行加工" [打印本页]

作者: fmt00    时间: 2018-6-19 10:50
标题: 如何实现“将窗体中通过系统自带筛选得到的结果记录进行加工"
access表格里自带了筛选功能,这省去了自己再写查找控件了。
但是筛选出结果后如何加工,比如打印,导出,勾选等功能。
在此请教。
作者: tmtony    时间: 2018-6-19 10:53
可将当前的recordsetclone 传递给报表 或将 当前的Filter 当成条件参数传递给报表(docmd.openreport ) 也是可行的
作者: fmt00    时间: 2018-6-20 22:12
受站长启发,在网上找了很久,都只找到传递给报表,而没有直接作用在窗体的。
自己经过了反复尝试,解决了这个问题。
反馈给大家:
(在主窗体中设置一个全选的选择框,在子窗体筛选后,对当前界面上的数据进行全选)
Private Sub CHK_全选是否_Click()
    Dim strwhere As String
    strwhere = Me.子窗体.Form.Filter
    strwhere = Replace(strwhere, "[子窗体名].", "") '获得的filter会保留子窗体的名字,如果不去掉,在主窗体运行时sql出错
    strwhere = Replace(strwhere, """", "'") '还要去掉双引号
    If strwhere <> "" Then
        strwhere = "where" & strwhere
    End If
    Me.子窗体.Form.RecordSource = "select * from 表  " & strwhere
    If Me.CHK_全选是否 = True Then
        CurrentDb.Execute "update 表 set 批量选择=true " & strwhere
        Me.子窗体.Requery
    Else
        CurrentDb.Execute "update 表 set 批量选择=false " & strwhere
        Me.子窗体.Requery
        Me.子窗体.Form.Filter = Me.子窗体.Form.Filter
    End If
End Sub




欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3