Results 1 to 6 of 6
  1. #1
    cebrower is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2018
    Location
    Spring Lake, MI
    Posts
    110

    Saving column width in a subform

    I have a form with two subforms. See the attached screen shot. I just added the one on the right. I want to reduce the width of two columns in the new subform so that some of the fields that are farther to the right will be visible. I can change the widths manually, but when I close and reopen the main forms the field widths have not been retained. I have many other form with subforms where such changes are retained. Not sure why this subform is any different. Any help would be appreciated.
    Attached Thumbnails Attached Thumbnails Column Width.jpg  

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    you can autofit with:
    fsubSorm.Form.txtBox1.ColumnWidth = -2


  3. #3
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    For the most part, column width depends on the largest width of data in a given view of the records. In a table or datasheet view, double click the column separator and you'll get the width needed for that view. Scroll down and you may find a record where the data exceeds the width that was just set. Double click separator again and the column will get wider. AFAIK when your form opens the widths will be governed by the width of the data in the view even if you use the suggested setting. If you want to make it static, you can use the column width property in the form load event. I believe the value needs to be in Twips (appx. 1440 per inch).
    EDIT - I believe you can also set the column width in form view and save the form and it will re-open with those settings. However, this won't prevent anyone from altering the widths and saving, so a code solution is probably the only way to make it permanent.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,413
    You can also adjust datasheet field widths like this:
    Click image for larger version. 

Name:	size.png 
Views:	15 
Size:	19.3 KB 
ID:	40304
    Last edited by davegri; 11-25-2019 at 12:00 PM. Reason: hide email addresses

  5. #5
    cebrower is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2018
    Location
    Spring Lake, MI
    Posts
    110
    Thanks Micron. Using the ColumnWidth property works perfectly for this situation.

  6. #6
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    You're welcome.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. combo box column width not working
    By smg in forum Access
    Replies: 3
    Last Post: 05-01-2019, 12:26 PM
  2. Autosize a column's width and height?
    By Isla in forum Reports
    Replies: 1
    Last Post: 04-05-2016, 01:58 PM
  3. Replies: 3
    Last Post: 04-10-2015, 02:35 PM
  4. Replies: 2
    Last Post: 02-22-2012, 05:10 PM
  5. Replies: 0
    Last Post: 12-25-2008, 10:05 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums