change column width to fit data

Jacob Mathai

Registered User.
Local time
Today, 06:23
Joined
Sep 6, 2001
Messages
546
Is it possible to change all column widths to fit the data programatically?
I would like to see the code for it.
Thanks.
 
Jacob Mathai said:
Is it possible to change all column widths to fit the data programatically?
I would like to see the code for it.
Thanks.

Do you mean to redefine a table's structure for text fields to ensure that they are large enough to STORE the data, or are you referring to adjusting the width of control(s) on forms or reports to DISPLAY the data?

If storage is your issue, setting text field sizes to 255 doesn't really waste all of that space, as Access only uses enough space to store the actual text (plus some overhead). So I tend to just make text fields of size 255 if I am unsure how much text they may be required to store.

The second case is more complicated. Some more information on your problem may allow for a better response.
 
Thanks for the response.

I only want to adjust the width of columns to fit the data when I open the table. Of course, I can do that when the table is displayed by double clicking on the column title box. May be that is the solution I need.
 
It is usually considered a bad idea to use the table view to directly manipulate data. Purpose-built forms allow for better input control and data validation.

The 'rule of thumb' is:
Tables store data.
Queries manipulate stored data.
Forms allow on-screen input and output of data to tables (ideally via a query)
Reports output data to a 'permanent' media.
Code Modules are used only to perform tasks that queries cannot accomplish efficiently.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom