Results 1 to 8 of 8
  1. #1
    Join Date
    Feb 2006
    Posts
    37

    Unanswered: Changing Box Width Dynamically in VBA

    Hey everybody,

    I have what seems like it should be a fairly simple question but I can't seem to get the syntax right.

    I am trying to change the width of a box on one of my forms dynamically for formatting reasons. This is to be done in the after_update event from a control group. I just can't seem to get it right. I would assume it could be changed like most other properties.

    I have the following:

    Box81.Width =

    where Box81 is the name of the box. I have tried several differnt combinations of things after the equal but just can't seem to get it there. Any help would be greatly appreciated.

  2. #2
    Join Date
    May 2004
    Location
    New York State
    Posts
    1,178
    What is happening? Are you getting an error message? Is the box width changing incorrectly?

    Sam

  3. #3
    Join Date
    Feb 2006
    Posts
    37
    Quote Originally Posted by Sam Landy
    What is happening? Are you getting an error message? Is the box width changing incorrectly?

    Sam
    Currently the box width is not changing at all.

  4. #4
    Join Date
    May 2004
    Location
    New York State
    Posts
    1,178
    The width property is in "twips" (I gorget what the acronym stands for), where 1440 twips = 1 inch. If you want the width to change in VBA, you have to measure it in twips.
    This is in contrast to the width property in the property sheet, which is measured in inches.

    Good luck,
    Sam

  5. #5
    Join Date
    Feb 2006
    Posts
    37
    Quote Originally Posted by Sam Landy
    The width property is in "twips" (I gorget what the acronym stands for), where 1440 twips = 1 inch. If you want the width to change in VBA, you have to measure it in twips.
    This is in contrast to the width property in the property sheet, which is measured in inches.

    Good luck,
    Sam
    Sam,

    Thanks for your help. It is working perfectly now! It ended up being:

    Box81.Width = "6840"
    Box81.Width = "3300"

    Just had to do the calculations for the twips numbers.

    You are awesome. I don't even want to know how you knew that!

  6. #6
    Join Date
    May 2004
    Location
    New York State
    Posts
    1,178
    You want the truth? I tried it out in the immediate window, selected the word "width", pressed F1, and read until I found the answer.

    Sam

  7. #7
    Join Date
    Feb 2006
    Posts
    37
    Quote Originally Posted by Sam Landy
    You want the truth? I tried it out in the immediate window, selected the word "width", pressed F1, and read until I found the answer.

    Sam
    Well dang for the simple solutions...

  8. #8
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    If you do much of this kind of thing you might want to look at Stephan Leban's thing for automating this proceedure:

    http://www.lebans.com/autosize_textbox.htm

    I understand it automatically adjusts the width of the box to accomodate the data it holds.
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Posting Permissions

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