UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Font changing    
 
   
javirafy
post Jul 21 2007, 07:01 PM
Post#1



Posts: 279
Joined: 16-January 04



I have a text box in my detail section of a report whose height es 3" and a font tahoma 10. The text viewed in that box has about 100 characters but not all the characters appear in the text box. I want to change to tahoma 8 (example) so that all the characters can be seen in the textbox. If I can see the text in the next line in the detail section I want to keep the font tahoma 10.
Can I do that via code?
Go to the top of the page
 
niesz
post Jul 21 2007, 10:11 PM
Post#2


Utter A-fishin'-ado
Posts: 17,958
Joined: 1-August 05
From: Cincinnati, Ohio, USA . . . ><((((°>


I don't think you'll find this as straightforward as you might think. Tahoma is a TrueType font, meaning that character sizes are not fixed. In other words, 10 upper case W's are not the same size as 10 lowercase i's.
x.
WWWWWWWWWW
iiiiiiiiii
So you cannot just say after 100 chars, change the font size. Well, you could, ... but there's no guarantee that it will display them all.
Even so, if you want to test it, you can change the font by a statement like:
Me.Text1.FontSize = 10
For a report, you may need to use the OnFormat event.
Go to the top of the page
 
javirafy
post Jul 22 2007, 10:13 AM
Post#3



Posts: 279
Joined: 16-January 04



Thank you!!! I'll try your suggestions
Go to the top of the page
 
niesz
post Jul 22 2007, 11:56 AM
Post#4


Utter A-fishin'-ado
Posts: 17,958
Joined: 1-August 05
From: Cincinnati, Ohio, USA . . . ><((((°>


NP.
Go to the top of the page
 
JeffK
post Jul 23 2007, 09:05 AM
Post#5


UtterAccess VIP
Posts: 1,550
Joined: 19-December 02
From: Lansing, MI


There is a very nice, seldom-used, report method you can make use of to do what you want. It's called TextWidth. TextWidth is aware of how each font operates and tells you the width of the text you specify based on the current fontname and fontsize supplied to the report.
attached an example displaying the use of the property. Basically, you check the TextWidth value of the text inside the box on the detail section's format event and change the font size if it's over a certain amount. This doesn't depend on any certain number of character but the actual pixel width of the resulting text so it works very well.
Enjoy,
Jeff
Attached File(s)
Attached File  UsingTextWidth.zip ( 12.71K )Number of downloads: 5
 
Go to the top of the page
 
niesz
post Jul 23 2007, 09:33 AM
Post#6


Utter A-fishin'-ado
Posts: 17,958
Joined: 1-August 05
From: Cincinnati, Ohio, USA . . . ><((((°>


Nice solution, Jeff. I couldn't open your attachment as all I have at work is Access 2000, but if it works as you claim, it should be just what the OP needs.
There may also be some new tools available in Access 2007 to help with this also.
Go to the top of the page
 
JeffK
post Jul 23 2007, 10:20 AM
Post#7


UtterAccess VIP
Posts: 1,550
Joined: 19-December 02
From: Lansing, MI


Here's a 2000 version. The odd part of the code is setting the report's Font properties - not often used but necessary for TextWidth to work right. TextWidth is essentially telling you "how wide would this text be in twips if it were to print right on the report canvas" - to answer that it has to know what the report's canvas' font properties are, so the code sets them to match the interrogated textbox.
Attached File(s)
Attached File  UsingTextWidth2000.zip ( 10.8K )Number of downloads: 6
 
Go to the top of the page
 
niesz
post Jul 23 2007, 10:39 AM
Post#8


Utter A-fishin'-ado
Posts: 17,958
Joined: 1-August 05
From: Cincinnati, Ohio, USA . . . ><((((°>


Nice. I didn't even know the report canvas had a Font setting all to it's own. Good info. thumbup.gif
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    17th December 2017 - 03:19 AM