Rendering failure on printing report

BLS

New member
Local time
Today, 00:50
Joined
Nov 24, 2016
Messages
7
I have a report that I can see in PrintPreview but it will not print or export to pdf word etc with a rendering issue.
It is a single page report split into 6 columns. I pull data to the top of each column only. The rest of all columns have 26 boxes (Rectangles)
In the detail format section I have code looping to format the boxes
First column boxes are widest
1. Me("Box" & intBoxNo).Width = 1800
subsequent column boxes are set by
2. Me("Box" & intBoxNo).Width = 1000
3. Me("Box" & intBoxNo).Left = 500

If I remove line 3. there is no issue
With line 3 I see it correctly in printpreview but it will not print or export. The error message is
"A Custom macro in this report has failed to run and is preventing the report from rendering"
(all to make it look nice??)
Any Suggestions please
 
Do you PrintPreview the report first, and they try to print or PDF it from the preview? If so, keep in mind that on that second run, all your variables and control positions--and so on--have already been assigned values from the first run, and those values are still "live." So if you have a report-global variable like...
Code:
Dim m_count as integer
...which is incremented everytime the detail section prints, like...
Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    m_count = m_count + 1
End Sub
...then m_count does not equal zero when you start your final print, or print to pdf operation. m_count will still contain the last value it had when the Preview operation completed. This can cause an expected failure because maybe you end up moving controls off the page, or doubling certain other values, and so on. Try printing directly, not from the preview, and see if that solves it.
 
MarkK
Thanks for the response.
I tried printing directly which failed as it was too wide.

I'm not sure that is the case with my code see below. I thought my code would start correctly as I set the numbers at the beginning of the code. Or am I missing your point?
I did reduce the left value to 50 and it would print. But display was not very good to look at.

Looking at the report I only see one column on numerous pages.
In PrintPreview I see the 6 columns. Which I would assume is correct.

Dim bolName As Boolean
Dim intBoxNo As Integer

If Me.txtEventDate = "" Then bolName = True
intBoxNo = 20
If bolName = True Then
Do Until intBoxNo = 50
Me("Box" & intBoxNo).Width = 1800
intBoxNo = intBoxNo + 1
Loop
Else
Do Until intBoxNo = 50
Me("Box" & intBoxNo).Width = 1000
Me("Box" & intBoxNo).Left = 500
intBoxNo = intBoxNo + 1
Loop
End If

BLS
 
Last edited:
MarkK
Thanks again for your response. After los of testing and failing finally cracked it.
The issue as you so rightly stated was rerunning the procedure.
I could not trap the error within the exporting procedure.
My data was only 6 columns on one page. but there were two runs to print or export.
Adding code into the Detail Format
If intCount = intRecords + 1 Then
intCount = 1
End If

Solved the issue once I had the design page more than wide enough.
Yippeee
A Big Thank you to MArkK
 

Users who are viewing this thread

Back
Top Bottom