How can I centre-align conditional a field in report using VBA?

mtawfik

New member
Local time
Tomorrow, 00:07
Joined
Nov 16, 2017
Messages
5
I have a report such a certificate, I need to adjust the certificate tittle to be center dynamically with another field.. Kindly note: the certificate tittle has different lengths, between 50 and 40 characters.
 
Unless I'm missing something, just center align the textbox holding that field.
 
Thanks for reply, this textbox contents are variant length and this field should be centered with another above textbox (fixed legnth)
 
So make them both the same width, wide enough to accommodate the longest value, and center both.
 
Something like this:

Code:
[I]text-box[/I] = Trim$( [I]source-of-text[/I] )
[I]text-box[/I].TextAlign = acCmdAlignCenter

Points:

1.) Be sure to remove leading and trailing spaces, Trim$ being one easy way to do that, because, well, ... spaces take up space too. So they contribute to position.

2.) I looked for other constants for this. I know that .TextAlign is the right property and I could not find another constant for text centering that was Access-only. Office, Excel, and Word each have their own named constants, but that's all I could find for Access.

3.) Having answered the question, I have to say I have never found a situation where this needed to be dynamic for me. I usually just did this in the Design mode of the form and left there as a static setting rather than a dynamic one.
 
I just do it in design view as well.
 

Users who are viewing this thread

Back
Top Bottom