ajgarrison
New Member
- Joined
- Jun 16, 2019
- Messages
- 10
I have a fixed size text box for printing labels. I would like to change the font size based upon the length of text in the field.
I have tried various methods I found on the internet, but all return a zero for my width.
This is the latest I tried and I have this on the Detail section onFormat:
Dim lngTextHeight As Long
With Me.NameTxt
'Copy the original Font height from the Tag property
.FontSize = .Tag
Do While .FontSize > 2
lngTextHeight = fTextHeight(Me.NameTxt)
'Does text fit? If yes then exit
If lngTextHeight < .Height - 72 Then Exit Do
'Decrease font height
.FontSize = .FontSize - 1
Loop
End With
By the way I am using Access 2013.
Can anyone help me understand why ftextheight() or ftextwidth() always returns 0? My text box is 6" x 3" and the shortest text I have would be something like Prednisone Tablets USP, 20 mg.
Thanks in advance!
I have tried various methods I found on the internet, but all return a zero for my width.
This is the latest I tried and I have this on the Detail section onFormat:
Dim lngTextHeight As Long
With Me.NameTxt
'Copy the original Font height from the Tag property
.FontSize = .Tag
Do While .FontSize > 2
lngTextHeight = fTextHeight(Me.NameTxt)
'Does text fit? If yes then exit
If lngTextHeight < .Height - 72 Then Exit Do
'Decrease font height
.FontSize = .FontSize - 1
Loop
End With
By the way I am using Access 2013.
Can anyone help me understand why ftextheight() or ftextwidth() always returns 0? My text box is 6" x 3" and the shortest text I have would be something like Prednisone Tablets USP, 20 mg.
Thanks in advance!