A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

'font size to fit' textbox



 
 
Thread Tools Display Modes
  #1  
Old May 29th, 2004, 02:39 PM
Dale Walker
external usenet poster
 
Posts: n/a
Default 'font size to fit' textbox

Anyone know how to dynamically reduce the font size of text within a
textbox so that all text within a field will always be printed on one
line?

I'm not talking about text wrapping or (CanGrow/CanShrink) type
functions.
  #2  
Old May 29th, 2004, 03:31 PM
SA
external usenet poster
 
Posts: n/a
Default 'font size to fit' textbox

Dale:

Stop by www.lebans.com, Stephen has a utility that can assist you here, look
in the downloads area I believe.
--
Steve Arbaugh
ACG Soft
http://ourworld.compuserve.com/homepages/attac-cg

"Dale Walker" wrote in message
...
Anyone know how to dynamically reduce the font size of text within a
textbox so that all text within a field will always be printed on one
line?

I'm not talking about text wrapping or (CanGrow/CanShrink) type
functions.



  #3  
Old May 29th, 2004, 03:33 PM
Stephen Lebans
external usenet poster
 
Posts: n/a
Default 'font size to fit' textbox

http://www.lebans.com/autosizefont.htm
AutoSizeFont.zip is a database containing a function to automatically
resize a Control's Font to fit the current record's contents. Works in
the Form's Current and/or Change events.

Version 2: Updated to use the new ,more accurate, fTextHeight function.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


"Dale Walker" wrote in message
...
Anyone know how to dynamically reduce the font size of text within a
textbox so that all text within a field will always be printed on one
line?

I'm not talking about text wrapping or (CanGrow/CanShrink) type
functions.


  #4  
Old May 29th, 2004, 04:25 PM
Dale Walker
external usenet poster
 
Posts: n/a
Default 'font size to fit' textbox

On Sat, 29 May 2004 11:33:15 -0300, "Stephen Lebans"
wrote:

http://www.lebans.com/autosizefont.htm
AutoSizeFont.zip is a database containing a function to automatically
resize a Control's Font to fit the current record's contents. Works in
the Form's Current and/or Change events.

Version 2: Updated to use the new ,more accurate, fTextHeight function.


Works great in Forms but how do I get it to work in Reports?

-------------------------------------------------------------
Dale Walker:
London Techno Events:
, london.sorted.org
Saiko:
, saiko.sorted.org
  #5  
Old May 29th, 2004, 06:12 PM
Stephen Lebans
external usenet poster
 
Posts: n/a
Default 'font size to fit' textbox

The code in the sample Form must be copied to your Report.

Form Load event - Report Open event
Form Current event - Relevant Report Section Format event(Detail in
most cases)


--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


"Dale Walker" wrote in message
...
On Sat, 29 May 2004 11:33:15 -0300, "Stephen Lebans"
wrote:

http://www.lebans.com/autosizefont.htm
AutoSizeFont.zip is a database containing a function to automatically
resize a Control's Font to fit the current record's contents. Works

in
the Form's Current and/or Change events.

Version 2: Updated to use the new ,more accurate, fTextHeight

function.

Works great in Forms but how do I get it to work in Reports?

-------------------------------------------------------------
Dale Walker:
London Techno Events:
, london.sorted.org
Saiko:
, saiko.sorted.org


  #6  
Old June 1st, 2004, 02:01 AM
Dale Walker
external usenet poster
 
Posts: n/a
Default 'font size to fit' textbox

On Sat, 29 May 2004 14:12:11 -0300, "Stephen Lebans"
wrote:

The code in the sample Form must be copied to your Report.

Form Load event - Report Open event
Form Current event - Relevant Report Section Format event(Detail in
most cases)


Sorry, still not working. Code barfs at the me.repaint line (compile
error: method or data member not found).

Doesn't .repaint only apply to forms?

-------------------------------------------------------------
Dale Walker:
London Techno Events:
, london.sorted.org
Saiko:
, saiko.sorted.org
  #7  
Old June 1st, 2004, 02:44 AM
Stephen Lebans
external usenet poster
 
Posts: n/a
Default 'font size to fit' textbox

The Repaint method is only for Forms - just comment it out.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


"Dale Walker" wrote in message
...
On Sat, 29 May 2004 14:12:11 -0300, "Stephen Lebans"
wrote:

The code in the sample Form must be copied to your Report.

Form Load event - Report Open event
Form Current event - Relevant Report Section Format event(Detail in
most cases)


Sorry, still not working. Code barfs at the me.repaint line (compile
error: method or data member not found).

Doesn't .repaint only apply to forms?

-------------------------------------------------------------
Dale Walker:
London Techno Events:
, london.sorted.org
Saiko:
, saiko.sorted.org


  #8  
Old June 1st, 2004, 03:50 AM
Dale Walker
external usenet poster
 
Posts: n/a
Default 'font size to fit' textbox

On Mon, 31 May 2004 22:44:48 -0300, "Stephen Lebans"
wrote:

The Repaint method is only for Forms - just comment it out.


Tried that, no errors but no size change either.

One thing that might conceivably be a problem is that I'm using
Japanese characters instead of ASCII.

Also using Access 2003.



-------------------------------------------------------------
Dale Walker:
London Techno Events:
, london.sorted.org
Saiko:
, saiko.sorted.org
  #9  
Old June 1st, 2004, 04:37 AM
Stephen Lebans
external usenet poster
 
Posts: n/a
Default 'font size to fit' textbox

You said the sample Form worked on your system so you should be able to
get the Report working as well.

I just saved the Sample Form as a Report.

Copied the Form's Load event to the Report's Open event.
Copied the Form's Current event to the Report Detail Section's Format
event and everything worked fine.

Here is the code behind my Report.


Option Compare Database
Option Explicit



Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim lngTextHeight As Long

With Me.txtExtraInfo
' Copy the original Font height from the Tag property
.fontsize = .Tag
Do While .fontsize 2
lngTextHeight = fTextHeight(Me.txtExtraInfo)

' Does text fit? If yes then exit
If lngTextHeight .Height Then Exit Do

' Decrease font height
.fontsize = .fontsize - 1
Loop
End With
End Sub

Private Sub Report_Open(Cancel As Integer)
' Copy the TextBox default Fontsize to its Tag property.
Me.txtExtraInfo.Tag = Me.txtExtraInfo.fontsize
End Sub

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


"Dale Walker" wrote in message
...
On Mon, 31 May 2004 22:44:48 -0300, "Stephen Lebans"
wrote:

The Repaint method is only for Forms - just comment it out.


Tried that, no errors but no size change either.

One thing that might conceivably be a problem is that I'm using
Japanese characters instead of ASCII.

Also using Access 2003.



-------------------------------------------------------------
Dale Walker:
London Techno Events:
, london.sorted.org
Saiko:
, saiko.sorted.org


  #10  
Old June 2nd, 2004, 01:58 AM
Dale Walker
external usenet poster
 
Posts: n/a
Default 'font size to fit' textbox

On Tue, 1 Jun 2004 00:37:58 -0300, "Stephen Lebans"
wrote:

You said the sample Form worked on your system so you should be able to
get the Report working as well.


I think I've spotted the problem. It occurs in both form and report
versions.

To make Japanese 'vertical' text, I was making the width of the
textbox just one character wide, so that the sentence would wrap down.

I've got a feeling Access (or the code) can't work out the correct
width of doublebyte characters and therefore miscalculates the number
of lines needed to fit in the height of the textbox. If I add a
newline between characters (or before any wrapping takes place for
wider examples), it works fine.

I'll have a go at rejigging the code but I'm that hot on VB
(especially when jiggling with twips and wotnot)

Also, I don't suppose you have a horizontal font scaler knocking
around anywhere (one that'll stick the whole field on one line)?

That'll come in handy for the next little projectette I have.


-------------------------------------------------------------
Dale Walker:
London Techno Events:
, london.sorted.org
Saiko:
, saiko.sorted.org
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:52 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.