Centering Text Box

Nimrod146

Registered User.
Local time
Yesterday, 18:53
Joined
Feb 11, 2007
Messages
11
Good Evening,

I have just started using Access 2007 :confused: , so I need a little bit of advice please.

When inserting a text box in form design view, is there an easy way to centre the box across the form. I could stretch it out from one side to the other, then centre the text, but there must be an easier way.

Many thanks

Gordon
 
You want it to automatically centre when you drop it onto the work area? Or are we talking in general, so it looks centred when you run the form?
 
Thanks for the prompt reply.

How could it be done both ways please?

If it was to be done automatically, would that have the same effect on other text boxes placed on the form too.

Your help is appreciated

Gordon
 
I was just getting you excited there regarding the drop-centre effect Gordon, it's not possible :) I wish it was.

There isn't an easy way of doing it. You can use one control as your benchmark and centre other controls that have the same width on that. Selecting all controls and using the Align menu. You can also use the ruler as a guide too.

Dividing the width of your form in half and subtracting half the width of your control from that will give you the Left dimension of your control centred horizontally.
 
I've always found I've had to stretch it out across the form and then center the text.
 
Thanks for both your replies,

I have tried everything I can think of, and will have to use either the stretch method, or use other controls as a guide.

You would think that with such a powerful tool ... centering a box would be a piece of cake! lol :eek:


Both your help is appreciated

Gordon
 
Yes, it still has its drawbacks and improvements that could be made.
 
You can't always have it all. Let's wait for version 18 (i.e. 2020) ;)
 
I create a label at the top of the form, stretch it out the width of the form, place a large X in it, then select it and select Center from the Align Icon. Then I position all other controls on this X. When I'm done designing the form, I delete the original label.
 
I create a label at the top of the form, stretch it out the width of the form, place a large X in it, then select it and select Center from the Align Icon. Then I position all other controls on this X. When I'm done designing the form, I delete the original label.

A cool way of doing it.
 
I like the use of a large X missinglinq. What were you referring to when you said the Align Icon?

The ruler is a good tool for knowing when your controls are centered too. I think alot of people forget it exists and never bother using it.
 
True, the ruler is one of the best tools.

You can align boxes and controls quite accurately using the ruler, then use properties to align exactly.


Gordon
 
The way I'd do this is to code it to start with - do something like textbox.left=textbox.width-(form.width/2). That should centre it.... I think...
 
The way I'd do this is to code it to start with - do something like textbox.left=textbox.width-(form.width/2). That should centre it.... I think...
Same idea with post #4, however, I think you would swap the values at both ends of the minus operator and you would want to subtract half the width of the text box as well to get the correct Left:

(form.width/2) - textbox.width/2
 

Users who are viewing this thread

Back
Top Bottom