Eljefegeneo
Still trying to learn
- Local time
- Today, 06:27
- Joined
- Jan 10, 2011
- Messages
- 902
Using Access 2010.
I have the following code to print out three versions of a contract report, differing only in footer on the report set by the OpenArgs. The OpenArgs to set the footer for each copy of the contract are set as A, B and C. They are set in the OnLoad of the report.
The code I use is:
The problem is that running code this the application stops working (non-responding) and then crashes. Strangely enough, on my home computer not connected to any network although I have split the DB, it works OK, but on my office computer where the back end is on the server, it crashes. I have the same amount of memory, 4 GM on each, so that might not be it. So it might be that the server connection is not fast enough for the code to run without hanging up.
What I would like to know is if my code above is optimal or could it be improved. Or what else might be causing the problem.
I have the following code to print out three versions of a contract report, differing only in footer on the report set by the OpenArgs. The OpenArgs to set the footer for each copy of the contract are set as A, B and C. They are set in the OnLoad of the report.
The code I use is:
Code:
' --- Note that there are OpenArgs to set the footer for each contract
DoCmd.OpenReport MyRpt, acViewPreview, , "[SequenceNumber] = " & Me![SequenceNumber], , "A"
'Saves the report as a PDF file in the proper directory, only needed once.
DoCmd.OutputTo acOutputReport, MyRpt, acFormatPDF, MyPath & MyFileName, False
DoCmd.PrintOut
DoCmd.Close acReport, MyRpt
DoCmd.OpenReport MyRpt, acViewPreview, , "[SequenceNumber] = " & Me![SequenceNumber], , "B"
DoCmd.PrintOut
DoCmd.Close acReport, MyRpt
DoCmd.OpenReport MyRpt, acViewPreview, , "[SequenceNumber] = " & Me![SequenceNumber], , "C"
DoCmd.PrintOut
DoCmd.Close acReport, MyRpt
End If
What I would like to know is if my code above is optimal or could it be improved. Or what else might be causing the problem.