Change font size in subreport when number value is large (1 Viewer)

cricketbird

Registered User.
Joined
Jun 17, 2013
Messages
108
I have a subreport that is fairly crowded. The fields are big enough to display four digit numbers, but not larger. This works 99% of the time, but occasionally there's a larger number that turns into #### instead of displaying. On the rare occasion of a large number, I'd like to reduce the font size so there's a greater chance of it displaying correctly.

I tried the following code in the subreport, but it doesn't seem to run. Is there a better way to do this?

Code:
Private Sub Report_Load()

If [Field1] > 9999 Or [Field2] > 9999 Or [Field3] > 9999 Then
   Me.Text1.FontSize = 9
   Me.Text2.FontSize = 9
   Me.Text3.FontSize = 9
End If

End Sub
 
Try using the Format or Print event.
Where are those events? In the Property Sheet > Events tab, I see no such events.

I did try conditional formatting, but size isn't an option.
 
Never mind! Found them in the "Details" section rather than in the control itself.

Fixed with the following code. There's probably a less cludgy way to do this, but it works:

Code:
    With Me.[Field1]
        If .Value > 9999 Then
            .FontSize = 9
        Else
            .FontSize = 12
        End If
    End With
    
    With Me.[Field2]
        If .Value > 9999 Then
            .FontSize = 9
        Else
            .FontSize = 12
        End If
    End With
    
    With Me.[Field3]
        If .Value > 9999 Then
            .FontSize = 9
        Else
            .FontSize = 12
        End If
    End With
 
Glad to hear you got it sorted out. Good luck with your project.
 

Users who are viewing this thread

Back
Top Bottom