(Msg. 1) Posted: Fri Oct 10, 2008 3:48 pm
Post subject: auto resize a text in a text box Archived from groups: microsoft>public>access>reports (more info?)
Hi, is there a way to auto resize a text to fill the text box. I want to use
this for a name tag to fill up the text box according to name's length. Thank
you in advance.
(Msg. 2) Posted: Fri Oct 10, 2008 6:53 pm
Post subject: Re: auto resize a text in a text box [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
Arlene wrote:
>Hi, is there a way to auto resize a text to fill the text box. I want to use
>this for a name tag to fill up the text box according to name's length. Thank
>you in advance.
What do you mean by "resize"?
If you mean change its FontSize and it fits on one line,
then try something like:
Dim fs As Integer
For fs = 14 To 5 Step -1
If TextWidth(Me.thetextbox) < Me.thetextbox.Width Then
Exit For
End If
Next fs
Me.thetextbox.FontSize = fs
(Msg. 3) Posted: Mon Oct 05, 2009 4:03 am
Post subject: Trying to do the same thing [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
Hi
Sorry for digging up an old thread but I have the same problem as Arlen. Trying to use the code you've provided, Marsh, but it's not quite working as expected. Can you help?
This is my full code, inc debugging info
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
Short
Height: 559 Width: 5265 TextWidth/Height:480/269 FONT SIZE: 4
Height: 559 Width: 5265 TextWidth/Height:480/269 FONT SIZE: 25
Very very very very long indeed
Height: 559 Width: 5265 TextWidth/Height:2818/269 FONT SIZE: 25
Height: 559 Width: 5265 TextWidth/Height:2818/269 FONT SIZE: 25
Quite long text
Height: 559 Width: 5265 TextWidth/Height:1330/269 FONT SIZE: 25
Height: 559 Width: 5265 TextWidth/Height:1330/269 FONT SIZE: 25
(the first line in each section is the value in the text box).
All of the text comes out the same size. I would expect the second value to have resulted in small text, but it gets cropped instead. As you can see, the TextWidth of that text is 2818, which is less than the width of the textbox (5265). But as the text is longer than the text box I'd have expected it to have been higher than 5265.
I've also tried the same code in Report_Page event but I either get text at 25 points or 5 points - nowhere in between.
Thanks in advance if you can help!
Nick
Marshall Barton wrote:
Re: auto resize a text in a text box
10-Oct-08
Arlene wrote:
What do you mean by "resize"?
If you mean change its FontSize and it fits on one line,
then try something like:
Dim fs As Integer
For fs = 14 To 5 Step -1
If TextWidth(Me.thetextbox) < Me.thetextbox.Width Then
Exit For
End If
Next fs
Me.thetextbox.FontSize = fs
(Msg. 4) Posted: Mon Oct 05, 2009 2:46 pm
Post subject: Re: Trying to do the same thing [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
Nick Thompson wrote: [snipped to essentials]
>Trying to use the code you've provided, Marsh, but it's not
>quite working as expected.
>
>Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
> Dim fs As Integer
>
> For fs = 25 To 5 Step -1
> Me.Text0.FontSize = fs
> If TextWidth(Me.Text0) < Me.Text0.Width Then
> Exit For
> End If
> Next fs
>End Sub
>
>All of the text comes out the same size. I would expect the second value to have resulted in small text, but it gets cropped instead. As you can see, the TextWidth of that text is 2818, which is less than the width of the textbox (5265). But as the text is longer than the text box I'd have expected it to have been higher than 5265.
Nothing in that code tells TextWidth what font size to use
so it's always using whatever the report's default font
size. I should be more like:
Dim fs As Integer
For fs = 14 To 5 Step -1
Me.FontSize = fs
If TextWidth(Me.thetextbox) < Me.thetextbox.Width Then
Exit For
End If
Next fs
Me.thetextbox.FontSize = fs
All times are: Eastern Time (US & Canada) (change)
Page 1 of 1
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum