Horizontally center text (1 Viewer)

actionashley

Josey Wales
Local time
Today, 01:30
Joined
Jun 16, 2010
Messages
39
Hello all,

I have a report (label actually) that i need to print and I wrote some code to adjust the font size based on the length of the text so it fits on the label. My problem is the text is always at the bottom of the text box so when it is small it doesn't look right. Here is my basic font control code:

If Len(Description) < 20 Then
Description.FontSize = 10
Else

If Len(Description) < 30 Then
Description.FontSize = 8
Else

Description.FontSize = 6

End If

End If

How do i center the text horizontally in the text box?
 

boblarson

Smeghead
Local time
Today, 01:30
Joined
Jan 12, 2001
Messages
32,059
Unfortunately, there is no way to do that with a normal Access text box. If you are using Access 2007 or 2010, you MIGHT be able to make it happen with a RICH TEXT text box or else it might need a "third-party" control.
 

actionashley

Josey Wales
Local time
Today, 01:30
Joined
Jun 16, 2010
Messages
39
Is there a way to adjust my top margin?

I can find the correct top margin spacing for each font size I specify, by trial and error, and set it accordingly.
 

actionashley

Josey Wales
Local time
Today, 01:30
Joined
Jun 16, 2010
Messages
39
:confused:My label is vertical so I actually need to adjust the right margin. I found the correct margin dimension, .025", and it works if I put it in the properties box but when I use this code it does not work. Any ideas what I am doing wrong.

If Len(Description) < 20 Then
Description.FontSize = 10

Else

If Len(Description) < 30 Then
Description.FontSize = 8
Else

Description.FontSize = 6
Description.RightMargin = 0.025


End If

End If
 

Users who are viewing this thread

Top Bottom