Results 1 to 3 of 3
  1. #1
    newbie is offline Advanced Beginner
    Windows XP Access 97
    Join Date
    May 2009
    Posts
    34

    Question Make a Rectangle Grow with Textbox

    I have a report that contains the fields drug name and drug cost. I have placed a rectangle behind the drug cost field so that it highlights the number. all is well until one of the drug names wraps to another line. When this happens I get a white space in the gray behind my text box. Is there a way to keep this from happening?

  2. #2
    slave138's Avatar
    slave138 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Oct 2010
    Location
    WI
    Posts
    233
    I don't know about Access 97 but in 2007 you can just set the Height & Width properties:

    Code:
    Me.Boxy.Height = Me.DrugCost.Height
    Me.Boxy.Width = Me.DrugCost.Width
    If it needs to be a little wider than the DrugCost field, just tack on the extra:

    Code:
    Me.Boxy.Width = Me.DrugCost.Width + 100
    Me.Boxy.Height = Me.DrugCost.Height + 50
    Just remember to adjust the Left and Top to account for the increased size:

    Code:
    Me.Boxy.Width = Me.DrugCost.Width + 100
    Me.Boxy.Height = Me.DrugCost.Height + 50
    Me.Boxy.Left = Me.DrugCost.Left - 50 'half of the increased width
    Me.Boxy.Top = Me.DrugCost.Top - 25 'half of the increased height
    You will probably want to associate the code with whatever action changes the DrugCost field.

    I forgot I was in the Reports section - this may only work on forms... Sorry.
    Last edited by slave138; 10-19-2010 at 05:29 PM. Reason: Correction

  3. #3
    slave138's Avatar
    slave138 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Oct 2010
    Location
    WI
    Posts
    233
    You might find this helpful:

    http://www.lebans.com/textwidth-height.htm

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

Similar Threads

  1. using textbox with In () in query
    By TheShabz in forum Forms
    Replies: 4
    Last Post: 04-10-2010, 12:00 PM
  2. Can Grow Property
    By chum in forum Reports
    Replies: 3
    Last Post: 01-25-2010, 11:10 AM
  3. Can Grow Property
    By MFeightner in forum Reports
    Replies: 0
    Last Post: 06-24-2009, 11:50 AM
  4. change() on the textbox
    By skywalker in forum Forms
    Replies: 0
    Last Post: 03-01-2009, 01:28 AM
  5. Textbox will not allow input
    By cwf in forum Forms
    Replies: 0
    Last Post: 04-04-2008, 04:08 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