Help on subreport

  • Thread starter Thread starter JACK GUNAWAN via AccessMonster.com
  • Start date Start date
J

JACK GUNAWAN via AccessMonster.com

I can not figure out how to know the number of times the report has been
printed whenever somebody print the same report.
In addition, how do I get the subreport on a report to display the same
product list (both in the subreport and report) while the list extends to 5
pages. Whenever I get to second page, the subreport still displays the first
page product list. Thanks. Please Help.

Jack
 
Jack,
Not sure about "elegance" but this works...
Let's say you have a report called rptTest.
Create a table called PrintCount with 2 fields, ReportName/Text/NopDupes
and PrintCount/Num/Integer
Populate the table with this data...
ReportName PrintCount
rptTest 0

Use the report Open event to run this code...

Private Sub Report_Open(Cancel As Integer)
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE tblPrintCount SET tblPrintCount.PrintCount =
NZ([PrintCount])+1 " & _
"WHERE (((tblPrintCount.ReportName)='rptTest'));"
DoCmd.SetWarnings True
End Sub

Be aware, that PrintPreview also constitutes a "print" and increments
the counter. If you have the report "hardwired" to always print directly to
a printer (with no PrintPreview), then this should work pretty well.
 
Al said:
Jack,
Not sure about "elegance" but this works...
Let's say you have a report called rptTest.
Create a table called PrintCount with 2 fields, ReportName/Text/NopDupes
and PrintCount/Num/Integer
Populate the table with this data...
ReportName PrintCount
rptTest 0

Use the report Open event to run this code...

Private Sub Report_Open(Cancel As Integer)
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE tblPrintCount SET tblPrintCount.PrintCount =
NZ([PrintCount])+1 " & _
"WHERE (((tblPrintCount.ReportName)='rptTest'));"
DoCmd.SetWarnings True
End Sub

Be aware, that PrintPreview also constitutes a "print" and increments
the counter. If you have the report "hardwired" to always print directly to
a printer (with no PrintPreview), then this should work pretty well.
I can not figure out how to know the number of times the report has been
printed whenever somebody print the same report.
[quoted text clipped - 6 lines]


Thanks for the assistance, Al Camp. However, I do not know how to use the
programing code. How to open the program code and do I just copy and paste
the code that you gave me. Thanks.
 
Jack,
1. Create the tblPrintCount table as I suggested, using your "real"
report
name instead of my sample "rptTest" name.
2. Open that Report in design mode. In the properties for the
Form itself, find the OnOpen property and put your cursor in the blank
text box to the right of that.
3 Click the little down arrow on the right, and select Event Procedure.
4. Click the button with 3 dots (...) on the right. You are now in the
module for the form, and you'll see this...

Private Sub Report_Open(Cancel As Integer)
(blank now, but our code will go here)
End Sub

This is where we'll post the code that will execute whenever the report
"Opens"... which it will whenever it prints.

Now insert my code between the lines... so it looks just like this
(use your report name in place of my 'rptTest')

Private Sub Report_Open(Cancel As Integer)
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE tblPrintCount SET " & _
"tblPrintCount.PrintCount = NZ([PrintCount])+1 " & _
"WHERE (((tblPrintCount.ReportName)='rptTest'));"
DoCmd.SetWarnings True
End Sub

Each time the report is printed or previewed, the counter in tblPrintCount
will increment.
--
hth
Al Camp
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions


JACK GUNAWAN via AccessMonster.com said:
Al said:
Jack,
Not sure about "elegance" but this works...
Let's say you have a report called rptTest.
Create a table called PrintCount with 2 fields,
ReportName/Text/NopDupes
and PrintCount/Num/Integer
Populate the table with this data...
ReportName PrintCount
rptTest 0

Use the report Open event to run this code...

Private Sub Report_Open(Cancel As Integer)
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE tblPrintCount SET tblPrintCount.PrintCount =
NZ([PrintCount])+1 " & _
"WHERE (((tblPrintCount.ReportName)='rptTest'));"
DoCmd.SetWarnings True
End Sub

Be aware, that PrintPreview also constitutes a "print" and increments
the counter. If you have the report "hardwired" to always print directly
to
a printer (with no PrintPreview), then this should work pretty well.
I can not figure out how to know the number of times the report has been
printed whenever somebody print the same report.
[quoted text clipped - 6 lines]


Thanks for the assistance, Al Camp. However, I do not know how to use the
programing code. How to open the program code and do I just copy and paste
the code that you gave me. Thanks.
 
Back
Top