On Format event works but printed report is not the same

J

Jesse Aviles

I have code attached to a report On Format event and it works OK. What I
see on the screen is just what I want. When I print the report it when I
find problems. This is code used:

Option Compare Database
Option Explicit
Dim intDepth As Integer

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
'Scales detail section to fit boring log

On Error GoTo ErrorHandler

If IsNull(intDepth) Then
intDepth = 0
End If
'Position controls at the top to prevent misplacement
DepthTop.Top = 0
DepthBottom.Top = 0
USCS.Top = 0
Description.Top = 0
SampleSelected.Top = 0
GWObserved.Top = 0
sngResults.Top = 0
sngRecovery.Top = 0
Detail.Height = 300
Line41.Height = 300
Line42.Height = 300

If (Nz(DepthBottom) - intDepth) > 1 Then
Detail.Height = (DepthBottom - intDepth) * 300
intDepth = DepthBottom
DepthTop.Top = 0
DepthBottom.Top = Detail.Height - 300
USCS.Top = Detail.Height - 300
Description.Top = Detail.Height - 300
SampleSelected.Top = Detail.Height - 300
GWObserved.Top = Detail.Height - 300
sngResults.Top = Detail.Height - 300
sngRecovery.Top = Detail.Height - 300
Line41.Height = Detail.Height
Line42.Height = Detail.Height
End If

ExitHandler:
Exit Sub

ErrorHandler:
MsgBox "Error: " & Err.Number & vbNewLine _
& "Description: " & Err.Description, vbMsgBoxHelpButton, "Error during
format", Err.HelpFile, Err.HelpContext

GoTo ExitHandler

End Sub

The code works to "scale" the detail section based on an expression. Detail
section default height is 300 tweeps. If intDepth value for one record is
6, I want that record height to be 1800 tweeps. If intDepth was 2, I want
the height to be 600 tweeps. So far the code works great on the screen but
not so in paper. In paper, every record is printed at 300 tweeps.

The properties set above the second If statemet used to be on an Else clause
of the second statement. When it was like that, the report printed just
like it appeared on the screen. Problem was that as it formatted the next
record, it will not format itself to set the controls to the top of the
section thus keeping the value of the previous section (if the values were
higher than results for the current record). That is why I had to remove
them to before the if statement.

Hope this makes sense
Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top