Results 1 to 5 of 5
  1. #1
    New Lounger
    Join Date
    Sep 2003
    Location
    Camp Lejeune, North Carolina, USA
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Expanding a text box in form (2002)

    When creating a form ---

    How do I make the fields expand to fit the data length without allowing the person viewing the data access to change it? In other words, I want a person to see data in one field and make comments in a seperate field without changing the data in the original field. Currently, the field box does not change size relative to the data length. I have tried the "can grow" and "can shrink", however, that only seems to work when making a report.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Expanding a text box in form (2002)

    As you found out, Can Shrink and Can Grow don't work in a form, only in a report.

    To make a text box on a form "autosize" itself requires sophisticated programming, involving Windows API calls. Stephen Lebans has posted a freely downloadable example on his website: AutoSize TextBox. You will have to convert his database to Access 2000 or 2002 format to study it. To use the code, copy the modfAutoSizeTextBoxMulti module to your database, and adapt the code in the On Current event of the frmAutoSizeMultiLine form to your situation.

  3. #3
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Expanding a text box in form (2002)

    The usual approach for this kind of problem is to make the text box generously large, but also provide a scroll bar so that when someone gets particularly verbose, the text can be scrolled. In addition, you probably want to lock the control, but not disable it, so a person can click into the text, but not edit it.
    Wendell

  4. #4
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Jerusalem, Israel
    Posts
    708
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Expanding a text box in form (2002)

    check out Mark Lebans web site: http://www.lebans.com/autosize_textbox.htm


    He describes as such:
    Use the updated fTextWidth and fTextHeight functions for an accurate solution. TextHeightWidth is a replacement for the Report object's TextWidth and TextHeight methods. It is multiline aware and can work in both Report and Form views.



    NEW AutoSizeTextBox.zip Ver 3.0 is a database containing functions to automatically resize a TextBox control to fit the current fields contents.

    Use the DrawText API with the DT_CALCRECT Flag to calculate the control's dimensions required to hold the current data.

    Version 3.0 fixes several bugs. Additionally there is now 1 single function to handle both Single and Multiline displays.

  5. #5
    New Lounger
    Join Date
    Sep 2003
    Location
    Camp Lejeune, North Carolina, USA
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Expanding a text box in form (2002)

    Just wanted to drop a note to say thanks for all the comments. Very helpful...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •