PDA

View Full Version : Setting ".Top" property of text box causes error 2101. Why?



Hathman
01-04-2011, 12:35 PM
I have done this before in forms but not on reports, however, everywhere I've searched online says it can be done. Am I doing something wrong? The error message says: "Run-time error '2101' The setting you entered isn't valid for this property."

Here is my code. I highlighted the text in red where it crashes. The variable NextTopLabel evaluates to 3018 twips so I can't seem to understand where the problem is.


Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
Dim NextTopLabel As Double
Dim NextTopSection As Double
Dim TinySpace, SmallSpace, MediumSpace, BigSpace As Double
TinySpace = 0.0104 * 1440
SmallSpace = 0.0319 * 1440
MediumSpace = 0.0834 * 1440
BigSpace = 0.1569 * 1440
NextTopLabel = 0.1979 * 1440
NextTopLabel = NextTopLabel + SmallSpace + subrptAttendee4.Height + SmallSpace + subrptAttendee7.Height + BigSpace + (0.1875 * 1440) + BigSpace
NextTopSection = NextTopLabel + TinySpace
If Forms!MAIN!chkTollgate = False Then
Me!lblRemediation.Top = NextTopLabel
Me!subrptRemediation.Top = NextTopSection
NextTopLabel = NextTopLabel + Me!lblRemediation.Height + MediumSpace
NextTopSection = NextTopLabel + TinySpace
End If
If Forms!MAIN!chkRemediation = False Then
Me!lblFollowUp.Top = NextTopLabel
Me!subrptFollowUp.Top = NextTopSection
NextTopLabel = NextTopLabel + Me!lblFollowUp.Height + MediumSpace
NextTopSection = NextTopLabel + TinySpace
End If
End Sub

Hathman
01-04-2011, 01:24 PM
UPDATE: This code works for the On Format event but not for the On Print event. The problem is that I need it to fire during the On Print event because that's when I can determine the height of my sub-reports (crucial to placing fields below them). For some reason, the height of sub-reports is not known during the On Format event. Does anyone know how to determine the height of the sub-reports prior to the On Print event? I would like it to be in the On Open event but it seems like the height at that time is not data driven but design driven and therefore not correct.