Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Resize text boxes 1

Status
Not open for further replies.

casperthedog

Instructor
Jan 29, 2002
20
0
0
NZ
I have a form containing text boxes where each text box contains a word from a sentence (each word being the contents of a field in a database). How can I have the text boxes automatically resize and position themselves a few pixels to the right of the previous text box, so that when the borders are removed it looks like a normal typed sentence:

I want it to look like this...

I don't want it to look like this...

(I can do it in VB using the autosize property of a label but can't seem to see the same property in Access)
 
If you are just trying to display the data, it would probably be easier to use a single text box and concatenate the words together. I don't have a clue how to autosize a text box in Access, or if it is even possible. You could probably develop your own ActiveX Control to do this, but it sounds like a lot of trouble.

Best,

dz
 
You can resize any control on a form. It may not be what you want to do in this case because FoxProProgrammer's suggestion to cancatenate the sentences together is very easy will make the sentences look like they are one. If you had three sentences in TextBox1, TextBox2, and TextBox3 you could make their visible property false and squeeze them down to just a sliver of a verticle line and place them over to the side out of the way. Now need to see them at all. Then use the following:

Me![TextBoxCombined] = Trim(Me![TextBox1]) & " " & Trim(Me![TextBox2]) & " " & Trim(Me![TextBox3])

Set the CanGrow property of the control Me@![TextBoxcombined] to true and it will expand down to accommodate the full length of the text.

Just a little demo on changing the size of a control. Controls are placed on the form starting at the upper left most being (0,0) on the x/y grid. In the properties of a control you will se the Left, Top, Width, and Height. They display the location of each in Inches.
You can modify these properties but you do not use the display measurement annotation. You use TWIPS. (1440 twips per inch) If the Left property of your control is 1.5 inches from the left side of the form and you want it to move to the right by 2 inches, you do not update this property to 3.5". You update it to with an additional 2880 twips.

Example:
Me![Control1].Left = me![Control1].Left + 2880

This will move the control 2" to the right.
This works likewise with the Top, Height, and Width properties.

If you want a control to move to a particular spot on the form then, lets say 3.25 inches from the left edge then the following should be done. (3.25 x 1440 = 4689)
Me![Control1].left = 4680

I have used this successfully in providing for an EXPAND button for a Memo field Text Box where there isn't enough room to display the whole thing all of the time. But, when they click the Expand button I modify the left, top, height, and width properties to expand it to a large area with a vertical scroll bar for the user to view all of the Memo data. The button.caption property changes to to SHRINK. Another click will then return to control to its original postion and size.

I hope this helps you with your problem and gives you some insight into control size and placement manipulation. You can also have a little bit of fun with your friends by bouncing a Control button around the screen with each click of the Mouse button. The old moving button trick.

Bob Scriver

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top