Reputation: 369
I have an access database that basically has a form where you can lookup some of the database entries. User types in part number, I check that it exists and if it does I return a report with all the data organized in a nice easy-to-read way.
The problem is that, say I generate the report. And then go back to the Form to query for a different part, the report doesnt update or a new report isnt generated (even if I click the "View report" button multple times).
I was wondering if there is a way to generate a new report (with the same template, from same form, different parameters) and just be able to have multiple reports of the same template with different parts to compare or just to analyse.
Upvotes: 0
Views: 1830
Reputation: 2696
As forms can be used multiple times this should work with reports too. Try:
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
Keep in mind to put Report_
in front of reports name, like it is done with Form_
.
Code to open up to 25 report with one button (button named CommandOpenReports):
'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
Code stolen from Multiple Instances of a Report
Upvotes: 1