MS Access:使用相同的参数从同一查询创建多个报告

时间:2018-09-07 19:22:05

标签: ms-access

我有一个访问数据库,该数据库基本上具有一种形式,您可以在其中查找一些数据库条目。用户输入零件号,然后检查它是否存在,是否返回报告,并以易于阅读的方式整理所有数据。
问题是,比如说我生成报告。然后返回到表单以查询不同的部分,报表不更新或不生成新报表(即使我多次单击“查看报表”按钮)。
我想知道是否有一种方法可以生成新的报告(具有相同模板,相同格式,不同参数),并且仅能够具有相同模板的多个报告,但具有不同的部分以进行比较或分析。

1 个答案:

答案 0 :(得分:1)

由于表单可以多次使用,因此它也可以用于报表。试试:

Dim rtp1 As Report_yourReportsName
Dim rtp2 As Report_yourReportsName
Set rpt1=New Report_yourReportsName
Set rpt2=New Report_yourReportsName
rpt1.visible=True
rpt2.visible=True

请紧记将Report_放在报告名称之前,就像使用Form_一样。

使用一个按钮(名为CommandOpenReports的按钮)最多可打开25个报告的代码:

'1) Declare a global variable (in the module header, outside of the subroutine) like this:

 'Assume we'll never need more than 25 instances of the
 'same report open at once
 Dim rpt(1 To 25) As Report


Private Sub CommandOpenReports_Click()
Dim I As Long
'2) set a member of the global array equal to the specific instance, filter according to whatever criteria you'd like, and make the instance visible.
For I = 1 To 25
    If rpt(I) Is Nothing Then
        Exit For
    End If
Next
'open rptPOs in separate windows
Set rpt(I) = New Report_Bericht1
rpt(I).Filter = stLinkCriteria
rpt(I).Visible = True

End Sub

Multiple Instances of a Report 被盗的代码