473,503 Members | 1,697 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

shrink to fit like excel

2 New Member
can someone help me...

this is my problem...

I am generating a report where in i have a textbox with a fix length.. then i want that any datas that will be called out to that textbox will fit into the text box without resizing or editing the textbox...
(hence.. like shrink to fit property of a cell in MS Excel )..

please please please,,,....
thanks in advance...
Sep 13 '08 #1
5 14815
puppydogbuddy
1,923 Recognized Expert Top Contributor
1. Place the report in design view
2. higlight the textbox
3. invoke the property sheet for that textbox
4. set the "can Grow" and "can Shrink" properties to yes
Sep 13 '08 #2
nico5038
3,080 Recognized Expert Specialist
Access has no "shrink to fit property" for a text box.
All you can do is calculate the max length (in general 255 characters) and see or you can set the font size property from 8 to e.g. 6 to have the max text fit the text box e.g. when more than 150 characters are found.

Nic;o)
Sep 13 '08 #3
billyAccess
2 New Member
Thanks nico5038...

Another is that...
I tried to do that by using the TEXTHEIGHT command during the print or preview in the report but an error occurred...

It seam that access don't know this command..
Can show me how to do that??
Sep 14 '08 #4
nico5038
3,080 Recognized Expert Specialist
It's not the "Text height", but the "Font Size" property you need to manipulate in the OnFormat event like:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
  2.  
  3. If Len(Me.QuerySQL) > 150 Then
  4.   Me.QuerySQL.FontSize = 6
  5. Else
  6.   Me.QuerySQL.FontSize = 10
  7. End If
  8.  
  9. End Sub
  10.  
Nic;o)
Sep 14 '08 #5
saqassemi
1 New Member
copy these codes in a report details properties and on print event:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
  2. Dim ctl As Control, strText As Variant, strName As String
  3. ' This routine uses the TextWidth methods to determine the maximum size
  4. ' of font possible to ensure a text string is printed in full in the
  5. ' report's current font without loosing any characters.
  6.  
  7.     Me.ScaleMode = 1 ' set all measurments to twips
  8.  
  9.     For Each ctl In Me.Detail.Controls
  10.  
  11.         If ctl.ControlType = acTextBox Then
  12.  
  13.         strName = ctl.Name
  14.  
  15.             If Nz(ctl.Tag, "") = "" Then
  16.                 ctl.Tag = ctl.FontSize
  17.             End If
  18.  
  19.  
  20.         ' set the control's fontsize to a suitable large size to begin with
  21.             ctl.FontSize = ctl.Tag
  22.  
  23.         ' make sure the report font size is equal to the control's fontsize.
  24.             Me.FontSize = ctl.FontSize
  25.  
  26.         ' grab the text from the control
  27.             strText = ctl.Value
  28.  
  29.         ' evaluate the Loop until the text fits the Width of the box less 24%. Do this
  30.         ' by reducing the font size incrementally and re-testing the Loop's criteria.
  31.            If Len(strText) > 0 Then
  32.             Do Until TextWidth(strText) < ctl.Width '- (ctl.Width * 0.26)
  33.                 ctl.FontSize = ctl.FontSize - 1
  34.                 ' reset the report's font size so the TextWidth function will
  35.                 ' continue to track the reducing font size correctly.
  36.                 Me.FontSize = ctl.FontSize
  37.             Loop
  38.  
  39.         ' now evaluate for the height of the text to make sure it fits vertically
  40.             Do Until TextHeight(strText) < ctl.Height - (ctl.Height * 0.26)
  41.                 ctl.FontSize = ctl.FontSize - 1
  42.                 ' reset the report's font size so the TextHeight function will
  43.                 ' continue to track the reducing font size correctly.
  44.                 Me.FontSize = ctl.FontSize
  45.             Loop
  46.  
  47.         End If
  48.         End If
  49.  
  50.     Next ctl
  51. End Sub
May 13 '18 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
5694
by: R Camarda | last post by:
Help, I have a database that has a data file of 2GB and a log file of 31GB. In enterprise manager, when I choose shrink it says there is 30GB of unused space. When I shrink the database, it does...
5
18282
by: BashiraInTrouble | last post by:
Hi Friends, I have tried almost everything but I cant seem to shrink the transaction log. Executing DBCC SQLPERF(LOGSPACE) gives me this info: Database Log Size (MB) Log Space Used (%) ...
4
6711
by: Tommy.Vincent | last post by:
hi all, This will be a easy question for all out here. I have a database of 28GB. having 3 Data Files 22 GB, 3.58 Gb and 2.70 GB respectively. and a Transaction Log file of 156 mb. When i...
4
6886
by: Bob Richardson | last post by:
Is it possible for an image to SHRINK (both height and width, keeping same h/w ratio) when the browser's width is reduced? It's easy to have both h & w increase, as needed, to fill up 100% of the...
3
1813
by: Karen | last post by:
I am trying to make addresses print on a report. I have two fields for the street address, how do I make the second field not leave an empty space on the report? I want the city, state, zip to...
4
1735
by: Gary Bond | last post by:
Hi All, Can anybody point me to some 'how-to' documentation, tutorials, etc as to how to write a shrink/protect wrapper for .Net exes/dlls, (like the Shrinkwrap product for instance). I have...
12
11746
by: hallpa1 | last post by:
Hi all, I posted messages before about trying to purge many records (about 35%) of a 200Gig database. The responses gave me a lot to think about, especially regarding the indexes. But due to the...
3
2104
by: Galka | last post by:
Hello Environment: Windows XP, MS Access 2003. I'd like - in a report - to save space , when there is no company data. When there is, I print out company name, address, telephone number and...
6
8779
by: Major Drake | last post by:
Windows 2003 64 bit sp2 + SQL Server std 32 bit sp2 compability mode 90, recovery model simple. I have about 40 Gb database where is about 98% free space (I deleted data from tables). dbcc...
0
7199
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7074
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7273
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7322
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7451
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4667
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3150
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
374
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.