访问两个 Table 子报表 - String Where

Access Two Table SubReport - String Where

我有一个关于报告的快速问题。我有一个包含两个未绑定子报表的报表(数据来自两个不同的数据库并且不共享任何信息。我​​通常通过使用简单的 UI 到 select 不同的选项单独打开这些报表并生成字符串在哪里并打开报告,即

DoCmd.OpenReport str_rptname, acViewReport, , strWhere

strWhere 由 UI

现在我已将它们合并到一个报告中,其中的字符串不起作用。是否可以将 where 字符串传递给子表单?如果是这样,我将如何去做?有 another/better 方法吗?

谢谢!

据我所知,您在评论中正确地指出了问题所在:

I believe it is because the string where opens the main report and sets the filter there, but the sub reports are not bound so open unfiltered

因为子报表是未绑定的,所以您需要给它们一个完整的记录集,而不仅仅是一个 WHERE 子句。像这样:

dim whereClause As String
dim strRecordset as String

'***Build your where clause

strRecordset = _
  "SELECT yourColumns " & _
  "FROM yourTables " & _
  "WHERE " & whereClause

Me.subreport.recordset = strRecordset
Me.subreport.Requery

请求可能是可选的。