Dynamically Sizing Form Controls

T

Tony

Hi All,

I have a db that allows users to pull up records with a search form. When
the records are returned, they include basic information including Address,
City, State, and ZIP. I would like to format the address information as
follows:

Street Address
City, State ZIP

Since the length of the data that is returned to the City control is of
varying length, in cases where the City is short, the returned data looks
like this:

Street Address
City State ZIP

Is there a way for me to dynamically size the City control (a text box) such
that it can shrink and grow, like report controls? Then, I can position the
State control by adding the City controls width and left properties to come
up with the left property of the State control.

Thanks & Ciao,

Tony
 
A

Assaf

You can use 1 text box to concatenate all 3 values:

TextBoxCityStateZip = rst!City & ", " & rst!State & " " & rst!Zip

- Assaf
 
T

Tony

Assaf,

Thanks for the reply; good suggestion. It eliminates the need to add widths
to determine positioning and will work well. However, what if I need to
place a field to the right of the concatenated text box. I think I would
still need to dynamically size the concatenated box.

Thanks for the assistance & Ciao,

Tony
 
A

Assaf

Here's what you can do:

Adjust the width of textbox1 to fit the text inside it (see how below) and
then set the left prop of textbox2:
textbox2.left = textbox1.left + textbox1.width + howEverMuchSpaceYouWant

Stephen Leban's textbox sizing solution:
http://www.lebans.com/autosize_textbox.htm

HTH.

- Assaf
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top