Results 1 to 8 of 8
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,919

    Field overflow


    In code, when one is setting an unbound field in a report, is there a way to determine if the data will overflow the target field. I suppose with a mono-spaced font, one could know the character capacity of the target field and code accordingly, but not so with proportional spaced fonts.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    Have to know the size of the text field. It is possible to use VBA to get the properties of tables and fields. Or you could just hard code a value to check against in the control's BeforeUpdate event.
    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.

  3. #3
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,919
    I know easily the width of the unbound text box, both in inches and Twips. It's the length of the string to be placed in the text box that's the issue. I.e., will it fit when the text box is formatted.

    Dim strMyString as string
    strMyString = "Here is some text"

    Me.tbMyTextBox = strMyString 'Text box in my report

    Is the width of the text box control tbMyTextBox wide enough to hold strMyString without overflowing?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    I thought you wanted to check the length of the input against the allowed field size (number of characters).

    If I have a variable length input and using proportional font, I size the textbox to fit the allowed field size using the widest character - capital W. If the field size is 20 characters, then the textbox is sized to allow display of 20 W's.

    Or I set the textbox height to display at least two lines and activate the vertical scroll bar.

    Programmatically altering textbox dimensions to accommodate variable length string is not practical.
    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.

  5. #5
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,919
    Since the text box is in a report, vertical scroll bars aren't an option. The input strings are somewhat manageable and I do have the option of populating a second line in another text box, though at the expense of other data that would have to be omitted.

    We need a function like lgTwips = TwipLgth(strMyString, tbMyTextBox)
    Where the function returns the length in twips of strMyString when formatted according to the properties of tbMyTextBox. The returned value can then be compared to the known width of the text box control.

    I need to move on, so I'll mark this issue as resolved. Thanks for your thoughts June.
    Bill

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    Why is this a concern in report? Textbox can grow vertically in a report.
    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.

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    I said not practical but apparently not impossible. Review: http://www.lebans.com/autosize_textbox.htm
    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.

  8. #8
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,919
    Sorry for the delay in responding.

    I've captured a screen-shot of the detail section of the report, which is a multi-page directory of profiles. There are 10 profiles per page, two columns. One of the tightest arrangements I've encountered in years.

    As you look at the detail section, line 2 of 10 lines is the line subject to overflow to two lines in the line 2 text box. You gave me the idea to make that text box twice its previous height, which you can't tell from the screen-shot. In the "Detail_Format" code, the text string that is compiled out of the DB is tested for its length and the top properties of all 10 lines are adjusted to make room for the expended 2nd line if it exceeds a nominal value, which I determined empirically. Top two lines move up while lines 3 through 10 are shifted down. It is aesthetically undesirable to leave the lines shifted this way throughout the directory.

    Thanks for the ideas you seeded.
    Bill

    Click image for larger version. 

Name:	DirectoryDetailSection.jpg 
Views:	4 
Size:	54.8 KB 
ID:	18842

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

Similar Threads

  1. Overflow Error
    By pj33558 in forum Reports
    Replies: 1
    Last Post: 06-19-2014, 10:50 AM
  2. Replies: 2
    Last Post: 12-15-2013, 02:29 AM
  3. Overflow
    By Joe8915 in forum Forms
    Replies: 4
    Last Post: 10-28-2012, 05:21 PM
  4. Overflow
    By roar58 in forum Queries
    Replies: 1
    Last Post: 10-02-2012, 10:37 AM
  5. Overflow error - change field type in query?
    By Lady_Jane in forum Queries
    Replies: 6
    Last Post: 05-25-2011, 01:10 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