Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1080
  • Last Modified:

How to vertically align a textbox in a from/report?

I've been asked by one of our clients to make a text box in a report and a form
vertically aligned.

1-I can't use Top margin property because the length of the string in each
   record is different and sometimes it wraps 2 or several lines.
2-Leban's "VerticalJustification" doesn't work. If the user has used Alt+Enter to create
   new lines in a memo text Leban's solution works out. But in case the memo is a long
   one line string it doesn't work. (see the screen shot bellow)

any kind of help is much appreciated.
  • 8
  • 6
1 Solution
you need to make the testmemo control smaller

and set it's cangrow property to true....
MnInShdwAuthor Commented:
cdbeste thanks for your input but it ruins the design of the report.

The worst aspect of cangrow property is that it shifts the other controls.
is there any way to force the textbox that contains SUS304-2B not shifting down?

thank you.

Jeffrey CoachmanMIS LiasonCommented:
When a program "Centers" text, it "Pads" an equal space around the text.

So if a user pressed Alt-Enter at the start orf the data entry, then the padding will be added to the new line feeds, thus "Mis-centering" the text.

It is not clear from any of your screenshots *exactly* what the actual Source for the textboxes is.

In the second shot I an not even sure if this is what you want, or don't want.

FWIW, Access 2007 has new "Padding" settings you can investigate.


NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

MnInShdwAuthor Commented:
boag2000 I'm afraid I can't understand what you mean.

Here's the case:
I'm trying to vertically centerize a text box in a report.
Up to now, I was using Leban's "VerticalJustification" code for this purpose
But I realized that Leban's code works only when the data of a text box
is multi line. It means that if the data contained in a memo field is a long
one line data, even Leban's code is not able to centrize it.

My first screen capture is Leban's "VerticalJustification.mdb". I have added
a new record in the table. The memo field in the record I added is a long
one line string. It means that I didn't used Alt+Enter to create newlines
in this field.
The result of this record is shown on my first screen shot. As you see, the
contents of the memo text box is not vertically centrized.

Now this is my question:
Is it possible to vertically centrize a text box in a report when the
data of this text box is a long string?

as for this question :
>>>It is not clear from any of your screenshots *exactly* what the actual Source for the textboxes is.
the actual source for the text boxes is a table in the database. what else could it be?

thanks for any further suggestion.
Jeffrey CoachmanMIS LiasonCommented:

Again if the user pressed Alt-Enter 5 times, the vertical alignment will be off as your screenshot suggests because the "Padding used to center the text will be ontop of the Alt-Enter Line feeds"

In other words, as long a s use can presss Alt-Enter anytime they want, the Center alignment cannot be garenteed.

>>>It is not clear from any of your screenshots *exactly* what the actual Source for the textboxes is.
the actual source for the text boxes is a table in the database. what else could it be?
I meat that I cannot actually "See" this actual textbox source.
Is is bound or Unbound?
Can you post the actual object that stores this text?

MnInShdwAuthor Commented:

the problem is that the users doesn't press Alt-Enter at all. If they do it at least
once, Leban's code works perfectly. They don't press Alt-enter and type long
strings in memo fields. and it cause Leban's code stop working.

I would appreciate if you do me a favor and take a look at the attached
database. It's Leban's database without any modification.
Launch the database and open the customer form. Be sure it shows
the first record.
As you see the memo field is not vertically justified.
Now check the records 2,3,4,..... You'll noticed that the memo field
is justified.

the only difference between the first record's memo field with other records
is that it doesn't contain line breaks (Alt+Enter)

If you open Customer table and add at least one line breaks in memo field
by pressing Alt-Enter, the memo field in customer table in the first record
would be justified too.

It means that if a memo field contains line breaks, it's possible to justify
the textbox vertically. But if you eliminate the line breaks, it won't be
vertically justified.

Now here's my question.
Can you make the first record's memo to be vertically justified too?

Million thanks
Jeffrey CoachmanMIS LiasonCommented:
I'll try,

Can you post a sanitized version of your Database?

MnInShdwAuthor Commented:
Sorry for being late and thanks for your time.

Here's a sample one.
Jeffrey CoachmanMIS LiasonCommented:
Can you post a sample of your *Actual* database with you actual data in it?
(delete any sensitive data)
MnInShdwAuthor Commented:
thanks for trying to help, but it's a very complicated application with more than 30
tables and 63 forms plus 38 reports. It takes quite a long time to delete
un-necessary relationships/tables/forms.

I would appreciate if you work on the database from the above link.
If you can find a way around for the first record in the table, I can
apply your workaround to my database.

Million thanks.
Jeffrey CoachmanMIS LiasonCommented:

The file you posted is easilly "Fixed" buy adding the: VerticallyCenter to each text box.

The text then is centered for every textbox and every record.
    VerticallyCenter Me.txtcustomerID
    VerticallyCenter Me.txtcusname
    VerticallyCenter Me.txttestmemo
So I really do not know what this proves?

This is why I would like a real sample.
I never asked for the entire database, just post a table, form and report that exibits the issue you are having trouble with.


MnInShdwAuthor Commented:
VerticallyCenter is added to memo textbox, but when you open the form or
the report the first record is not centered vertically.

I haven't modified the structure of the above database. It's as it's offered
in Leban's homepage.
I've just added a record to the table.

anyway, if you need the database I'll send it tonight.
Give me several hours.

thank you
Jeffrey CoachmanMIS LiasonCommented:

"but when you open the form or the report the first record is not centered vertically. "
Mine is.
Here is a screenshot.

Am I mis-understanding something?


MnInShdwAuthor Commented:

thanks for your reply.
No you're not misunderstanding me. Your form shows up perfectly.
I wonder why mine is strange. The first image above is what I have.

It seems it's something just for me.
MnInShdwAuthor Commented:
Million thanks

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 8
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now