Results 1 to 10 of 10
  1. #1
    Paul H's Avatar
    Paul H is offline Expert
    Windows XP Access 2010 64bit
    Join Date
    Sep 2011
    Location
    Richmond, VA
    Posts
    591

    Freeze Columns in a Form?


    I've created a form that I am displaying as a Continuous Form so I have limited real estate on which to display the data entry fields needed. This means the right side of the form may scroll offscreen. As a matter of fact this is likely to happen. Is there a way to lock the first 2 or 3 fields onscreen as the user tabs through the data entry fields? Are their other alternatives I should explore?

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    I don't think you can lock items by column, someone probably has better knowledge than I do regarding datasheet type subforms (I design my own subforms to show what/where I want). You can still have a continuous form and design a form that shows everything on the space you have (assuming you don't have something huge) which may be an option for you.

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    To my knowledge it can't be done. The workarounds I've seen use 2 subforms kept in sync with each other. There are a couple here:

    http://www.access-programmers.co.uk/...d.php?t=208193
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    You CAN freeze columns in a datasheet however (I've done it for a project before).

    See this article:
    http://msdn.microsoft.com/en-us/libr...ffice.11).aspx

  5. #5
    Paul H's Avatar
    Paul H is offline Expert
    Windows XP Access 2010 64bit
    Join Date
    Sep 2011
    Location
    Richmond, VA
    Posts
    591
    Thanks for these idea, I will look into both suggestions and see if I can adapt for my project. I'll come back once I've digested this material.

    The bit I've seen of your suggestion Paul behaves very much like I would want my form to behave. I'll let you guys know what I come up with.

    Paul

  6. #6
    Paul H's Avatar
    Paul H is offline Expert
    Windows XP Access 2010 64bit
    Join Date
    Sep 2011
    Location
    Richmond, VA
    Posts
    591
    Paul,

    I found one that works on the UK site using two subforms and a module full of code I just plugged into my database. I'm happy with the way it behaves except for the way column widths work in datasheet view. I looked over some code that Bob pointed to that talks about this.
    http://msdn.microsoft.com/en-us/libr...ffice.11).aspx

    Before I try to wade through it does anyone have a simple way of setting the column width property of the data sheet? I undertand that this needs to be done at runtime using DAO. Finding DAO somewhat bewidering, I'd like to keep this simple as possible. A bit of generic code would be nice.

    Thanks,

    Paul Hammond
    Richmond, VA

  7. #7
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    Quote Originally Posted by Paul H View Post
    Before I try to wade through it does anyone have a simple way of setting the column width property of the data sheet? I undertand that this needs to be done at runtime using DAO. Finding DAO somewhat bewidering, I'd like to keep this simple as possible. A bit of generic code would be nice.
    Umm, no you don't need DAO to set the column width property of the datasheet view of a FORM (so use that instead of just a query or table displayed as a datasheet).

    Code:
    Me.ControlNameHere.ColumnWidth = 1000
    Or for the subform from the main form:
    Code:
    Me.SubformControlNameHere.Form.ControlNameHere.ColumnWidth = 1000
    adjust the number for the width to get the size you want. It is in TWIPS.

  8. #8
    Paul H's Avatar
    Paul H is offline Expert
    Windows XP Access 2010 64bit
    Join Date
    Sep 2011
    Location
    Richmond, VA
    Posts
    591
    Quote Originally Posted by boblarson View Post

    Code:
    Me.ControlNameHere.ColumnWidth = 1000
    That's certainly more understandable than the custom functions I was looking at, meaning I can do it myself. Without mucking it up to much is there a way to cycle through them and dynamically set each one to best fit? I came up with this.

    Code:
    Dim ctl As Control
    For Each ctl In Me.Controls
     
        ctl.SizeToFit
     
    Next ctl


    It lacks two things.
    1. I want to limit it to the text boxes (not sure how) and
    2. It doesn't do anything thing.

  9. #9
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    Here you go:

    Code:
    Dim ctl As Control
     
    For Each ctl In Me.Controls
       If ctl.ControlType = acTextBox Then
          ctl.ColumnWidth = -2
       End If
    Next
    The -2 is the key.

  10. #10
    Paul H's Avatar
    Paul H is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Location
    Richmond, VA
    Posts
    591
    Neat as a freak. Thanks!

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

Similar Threads

  1. Hiding columns in split form.
    By cementblocks in forum Forms
    Replies: 5
    Last Post: 03-11-2014, 07:16 AM
  2. Freeze panes in reports
    By Jamy in forum Reports
    Replies: 4
    Last Post: 01-02-2012, 03:19 PM
  3. Replies: 1
    Last Post: 05-23-2011, 07:11 AM
  4. Replies: 6
    Last Post: 02-28-2010, 05:46 PM
  5. using VBA to freeze columns
    By bdaniel in forum Forms
    Replies: 1
    Last Post: 02-12-2010, 05:36 AM

Tags for this Thread

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