Results 1 to 9 of 9
  1. #1
    KAR is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2013
    Posts
    4

    Programming Text Width in Access

    I want to program a textbox control's width to the size of it's calculated. So if the calculated output is 3.67 then I want the text box width to be 3.67". I'm very basic in my programming with Access and don't see how to do this. HELP!

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    You can set the Width property of the textbox:

    Me.TextboxName.Width = xxx

    Note the measurement is probably in twips not inches.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    KAR is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2013
    Posts
    4
    Thank you Paul. Bear with me. So where do I set this property for? I tried under Format Width and won't let me. I also tired in the OnClick under Events and I get an error. I'm such a novice but I feel like I'm trying to do something really simple and can't get it to work.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    What I posted was VBA, and would go here:

    http://www.baldyweb.com/FirstVBA.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    KAR is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2013
    Posts
    4
    Thanks again. I tired this as well before. I don't get the error any more but the text box doesn't change size - stays the same size as is in the Width property in the Format section. Not sure if it's because I'm using old Access 2007 or what.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Just tested and it worked as expected. Are you sure you didn't set the textbox to the size it already was? Are you sure code is running? Try adding a message box:

    MsgBox "setting width"
    Me.TextboxName.Width = 1000
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    KAR is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2013
    Posts
    4
    It looks as though the code is not running as I don't get that Msg Box. Thought I was going crazy! Not sure why code wouldn't be running?

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    How are you calculating the width? Are textboxes set for a non-proportional font?

    Is this code behind a continuous view form? Setting properties of controls in continuous view will affect all records.

    Did you select [Event Procedure] in the Click event property?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Quote Originally Posted by KAR View Post
    It looks as though the code is not running as I don't get that Msg Box. Thought I was going crazy! Not sure why code wouldn't be running?
    The db must be in a trusted location or you must explicitly enable code.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Access 2007 import fix width ANSI text file
    By jsama in forum Import/Export Data
    Replies: 0
    Last Post: 03-05-2013, 09:07 PM
  2. Text box width/bring to front and Checkbox
    By SorenIX in forum Programming
    Replies: 16
    Last Post: 06-22-2011, 06:07 PM
  3. Replies: 5
    Last Post: 02-20-2011, 08:22 PM
  4. export query to fixed width text
    By eladz949 in forum Import/Export Data
    Replies: 1
    Last Post: 02-08-2011, 07:28 AM
  5. export query to fixed width text
    By eladz949 in forum Import/Export Data
    Replies: 5
    Last Post: 01-01-2011, 03:28 PM

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