472,146 Members | 1,388 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,146 software developers and data experts.

Print Reports

Ian
(Sorry if I have repeated this, it did not appear the first time)

I have the following code on a button. The idea is that when this button is
clicked it prints several reports automatically then loops through several
other reports and prints them. These reports are not sent to a printer but
sent to a program called Fine Print PDF Factory which turns them into a PDF
file (set as the default printer)

This all works perfectly unless any of the reports have more than about
250-300 pages, if more than this then I occasionally get an error message
saying "Out Of Stack Space" or more often Access just closes in the middle
of a report without any message.

I am concerned about the (rst.Close) part, is this sufficient to return the
system memory? Should there be other specific command to do this? Does
anyone have any suggestions?

I have not tried sending it to a real printer as these reports contain
colour pictures and 300 of them would take a long time to test, I suppose
the problem could be with the PDF Factory but this seems unlikely as I have
printed long Word documents using it.

Many thanks in advance.



Private Sub Command134_Click()

On Error GoTo ErrReport

Dim dbs As Database

Dim rst As Recordset

Dim strSQL As String

Set dbs = CurrentDb()

Set rst = dbs.OpenRecordset("PrintDefaultsAssendingQuery") ' set to the
query

'added 7/7/03. print Cover first then Index report before other reports

'Check if any records first

Dim NumRecs As Long

NumRecs = DCount("[SortOrder]", "[TocCountQuery]", "[SortOrder]")

If NumRecs < 1 Then

MsgBox "There is No Data to print from any of the selected reports.",
vbCritical, "Error"

Exit Sub

End If

'Check if Outline Picture has been selected 24/07/03

Dim NumOutline As Long

NumOutline = DCount("[OutlineDrwaingImpSiteID]", "[OutlineCountQuery]",
"[OutlineDrwaingImpSiteID]")

If NumOutline < 1 Then

MsgBox "Please enter the Site Outline Picture before printing reports.",
vbCritical, "Error"

Exit Sub

End If

'print these first

DoCmd.OpenReport "SiteOutlineRep", acNormal, "", "" 'open the reports

DoCmd.OpenReport "NameAddressRep", acNormal, "", ""

DoCmd.OpenReport "IndexRep", acNormal, "", "" 'open the reports

With rst

..MoveFirst

Do Until .EOF

strSQL = rst![ActualName] 'The field name on the query

DoCmd.OpenReport strSQL, acNormal, "", "" 'open the reports

..MoveNext

Loop

rst.Close

End With

Exit_OpenCustRep_Click:

Exit Sub

ErrReport: 'Error checking

Select Case err

Case 2501 'the open report action was cancelled

Resume Next

Case Else

MsgBox Error$

End Select
Resume Exit_OpenCustRep_Click

End Sub




Nov 12 '05 #1
0 2073

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Wendy Elizabeth | last post: by
2 posts views Thread by Claudia Fong | last post: by
7 posts views Thread by Frank | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.