从子窗体 ms 访问的数据源中获取报表名称 vba
Get report name from DataSource of subform ms access vba
我有一个表单(比如 form1)可以导航到另一个表单(form2),该表单有一个子表单,该子表单基于通过选择 form1 上的文本框放入的数据源打开报告。
代码如下所示
Private Sub txt_DeliveryItemsSummary_Click()
DoCmd.OpenForm "frm_viewReports", acNormal
Forms!frm_ViewReports!subrpt_ReportArea.SourceObject = "Report.rpt_DeliveryItemsSummary"
End Sub
并且在 form2 上我有一个打印按钮来打印报告
代码看起来像这样
DoCmd.OpenReport subrpt_ReportArea.SourceObject, acViewNormal, , , acWindowNormal
但是这段代码给出了以下错误
Runtime Error 2103
您在 属性 sheet 或宏中输入的报告名称 'Report.rpt_DeliveryItemsSummary' 拼写错误或引用了不存在的报告。
任何帮助我如何解决这个问题。
非常感谢。
我自己想出来了。我知道我需要跳过一段文字,但是怎么做!我遇到了麻烦。
这是工作代码
DoCmd.OpenReport Right(subrpt_ReportArea.SourceObject, Len(subrpt_ReportArea.SourceObject) - 7), , acViewNormal, , , acWindowNormal
感谢@Gustav 再次联系我们。
我有一个表单(比如 form1)可以导航到另一个表单(form2),该表单有一个子表单,该子表单基于通过选择 form1 上的文本框放入的数据源打开报告。
代码如下所示
Private Sub txt_DeliveryItemsSummary_Click()
DoCmd.OpenForm "frm_viewReports", acNormal
Forms!frm_ViewReports!subrpt_ReportArea.SourceObject = "Report.rpt_DeliveryItemsSummary"
End Sub
并且在 form2 上我有一个打印按钮来打印报告 代码看起来像这样
DoCmd.OpenReport subrpt_ReportArea.SourceObject, acViewNormal, , , acWindowNormal
但是这段代码给出了以下错误
Runtime Error 2103
您在 属性 sheet 或宏中输入的报告名称 'Report.rpt_DeliveryItemsSummary' 拼写错误或引用了不存在的报告。
任何帮助我如何解决这个问题。
非常感谢。
我自己想出来了。我知道我需要跳过一段文字,但是怎么做!我遇到了麻烦。
这是工作代码
DoCmd.OpenReport Right(subrpt_ReportArea.SourceObject, Len(subrpt_ReportArea.SourceObject) - 7), , acViewNormal, , , acWindowNormal
感谢@Gustav 再次联系我们。