Solved

Dynamically position and resize textboxes horizontally in reports using Access 2003

Posted on 2009-07-14
4
479 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
  • 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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

838 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