访问报告-显示另一种形式的当前记录源 [英] Access Report - show current recordsource of another form

查看:63
本文介绍了访问报告-显示另一种形式的当前记录源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个报告,显示另一个表单的记录源.当我在此表单上添加一些记录并单击以获取报告时,不会显示该记录.我如何才能始终显示屏幕上的内容?这是我的简单报告代码:

I have a report that displays another form's recordsource. When I add some record on this form and click for report, this records is not being displayed. How can I achieve displaying what is on screen - allways ? Here is my simple code for report:

Private Sub cmdOpenReport_Click()

   DoCmd.OpenReport "MyReport", acViewReport

End Sub

Private Sub Report_Open(Cancel As Integer)

   Me.RecordSource = Forms![MyForm].Form.RecordSource

End Sub

推荐答案

我有一个答案,我知道这不是那么容易(在OpenReport按钮的单击事件中):

I have an answer, I knew It's not so easy (in click event of OpenReport button):

Dim strWhere As String

    Me.Dirty = False

    With Me.Recordset.Clone
        Do Until .EOF
            strWhere = strWhere & "," & !ID
            .MoveNext
        Loop
    End With
    strWhere = Mid(strWhere, 2)
    DoCmd.OpenReport "MyReport", acViewReport, WhereCondition:="ID In (" & strWhere & ")

由Leigh Purvis(访问MVP)提供的答案,非常感谢!

Answer provided by Leigh Purvis (Access MVP), a BIG thanks once more !!

这篇关于访问报告-显示另一种形式的当前记录源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆