Solved

Dynamically position and resize textboxes horizontally in reports using Access 2003

Posted on 2009-07-14
4
481 Views
Last Modified: 2013-11-28
Hi, I have a report in Access 2003 with 8 columns of data.  All columns (textboxes) are in the detail section of the report.  

When open or print this report, I would like Access to adjust the position of each column (textbox) and resize its width horizontally, based on the longest value of each column, that way it will be displayed and printed nicely without having any values being cut off.  Will you please help?  Thanks!
0
Comment
Question by:mulia
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 77

Accepted Solution

by:
peter57r earned 100 total points
ID: 24851595
Why can't you size them to the largest value as you design the report?
0
 

Author Comment

by:mulia
ID: 24851728
The base table for this report gets truncated and reloaded with new data each time the report gets printed out. I can get the largest value of each column, but how can I move the starting position of each textbox for each column?  Thanks for helping me out...
0
 
LVL 74

Assisted Solution

by:Jeffrey Coachman
Jeffrey Coachman earned 150 total points
ID: 24852366
Although I have seen code to "Dynamically resize" Texboxes/Comboboxes based on the number of characters, this code not:
1. For beginners
2. Perfect
Because of WYSIWYG fonts, the same amonut of characters do not always take up the same amount of "Space"
For example, this is 20 Characters:
iiiiiiiiiiiiiiiiiiii
So is this
WWWWWWWWWWWWWWWWWWWW

... as you can see the "W's" take up about 2/3 more space than the "i's"

In other words any "Real" code to do this would have to verify the character and the "Case" of the character in order to do this exactly.
(Most of the code to do this "Averages" the font by using "0" as a reference character.
(But you can see that this will not be perfect.)

This is just the "Size"
If this is not dependable, you can't hope to "Reposition" the texboxes.

Access does a fairly decent job of sizing the textboxes based on the  "FieldSize" property you set in the table.

JeffCoachman


0
 
LVL 74

Assisted Solution

by:Jeffrey Coachman
Jeffrey Coachman earned 150 total points
ID: 24856555
So if your question is: Can the resizing on the textbox be done...
The answer is yes, provided you are willing to calculate the dimensions of *Every* character in *Every* possible font in both upper and lower case.
If your question is if the textboxes can be moved dynamically based on the size of the textbox, the answer is again, Yes, provide you are willing to do all the above calculations and then calculate the space between the textboxes then calculate the distance the textbox should be from each other based on the above calculation plus the distance between the textboxes.

In other words, anything is possible.
If it worth the trouble, is another story.

I have never seen anything like this done in any reporting engine.
I have never had the need to do this myself

Again, if you use the Report Wizard, Access does a pretty good job of sizing the textboxes based on the Fieldsize property you set in the table.
Access also spaces the textboxes apart at a consistent distance.

So if your question is: Is there an "Easy/Quick/Simple" way to do this (and is it worth the trouble), then IMHO, the answer is No.

JeffCoachman
0

Featured Post

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question