If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Report Being Rerun in Print Preview and Print
Hello,
I have a report where I am using code to generate the data in the report. The data that is being rerun in the detail section and is creating inaccurate results. The issue I'm having is that data is being rerun. What is in the preview screen is not what is printed (we have all our reports set to preview as the users don't always print them after they're generated). I found some info regarding this "Access fires the events again when the report prints after preview, so you need to reset your variables in the Report Header's Format event. Report_Open does not fire again." I am not that familiar with code and am not sure of the code that I need to do this. I have this in the Header now Private Sub ReportHeader_Format(Cancel As Integer, FormatCount As Integer) End Sub Any info would be greatly appreciated |
#2
|
|||
|
|||
Report Being Rerun in Print Preview and Print
2005sporty wrote:
Hello, I have a report where I am using code to generate the data in the report. The data that is being rerun in the detail section and is creating inaccurate results. The issue I'm having is that data is being rerun. What is in the preview screen is not what is printed (we have all our reports set to preview as the users don't always print them after they're generated). I found some info regarding this "Access fires the events again when the report prints after preview, so you need to reset your variables in the Report Header's Format event. Report_Open does not fire again." I am not that familiar with code and am not sure of the code that I need to do this. I have this in the Header now Private Sub ReportHeader_Format(Cancel As Integer, FormatCount As Integer) End Sub The info you found is only sufficient in very simplistic reports. In general, you can not use code in a report's event procedures to calculate values that depend on anything beyond the fields in a single detail record. The common case where your problem is seen when you try to add the values of a field using code like: Dim total As Long Sub Detail_Format(... total = total + somefield End sub That kind of approach will fail to calculate a correct total because reports fire event procedures as many times and in whatever order is needed to lay out all the sections according to your various property settings. Generally, the aggregate functions should to calculate multi record totals. Or maybe the report requires a more sophisticated record source query that takes care of the calulations. -- Marsh MVP [MS Access] |
Thread Tools | |
Display Modes | |
|
|