Set Unbound Control TextAlign Property

  • Thread starter Thread starter Bob.Orta
  • Start date Start date
B

Bob.Orta

Access 2003, SP3

I have a database that serves as a letter writer. One of the reports
has several unbound controls that are controlled by seperate subs. I
have a need to change the alignment (and content, as always) of one of
the controls based on user selections on a data entry form. Although I
have been coding in Access since version 2.0, I have never had a need
to change a controls alignment property. So, I am unsure of the
syntax to do so. Below is a partial sample of one of my efforts to do
so, but it does not work:
Dim ctl As Control

Set ctl = Me.Controls("txtPara11")
ctl.Properties("txtPara11").TextAlign = "center"
strPara11 = "XXXXXXXXX XXXXXXXXX XXXXXXXXX
XXXXXXXXX XXXXX" & vbCrLf _
& "P.O. Box 9999999" & vbCrLf _
& "Hills, CA 99999-9010" & vbCrLf
.txtPara11 = strPara11

A workaround is to create another UB form and go from there, but I
would prefer not to do so. Code suggestions would be appreciated.

Regards,
Bob
 
Access 2003, SP3

I have a database that serves as a letter writer. One of the reports
has several unbound controls that are controlled by seperate subs. I
have a need to change the alignment (and content, as always) of one of
the controls based on user selections on a data entry form. Although I
have been coding in Access since version 2.0, I have never had a need
to change a controls alignment property. So, I am unsure of the
syntax to do so. Below is a partial sample of one of my efforts to do
so, but it does not work:
Dim ctl As Control

Set ctl = Me.Controls("txtPara11")
ctl.Properties("txtPara11").TextAlign = "center"
strPara11 = "XXXXXXXXX XXXXXXXXX XXXXXXXXX
XXXXXXXXX XXXXX" & vbCrLf _
& "P.O. Box 9999999" & vbCrLf _
& "Hills, CA 99999-9010" & vbCrLf
.txtPara11 = strPara11

Try using this in the Format event of the section that
contains the text box:
ctl.Properties("txtPara11").TextAlign = 2

VBA Help is your friend. In this case it says:

Setting Visual Basic
General 0
Left 1
Center 2
Right 3
Distribute 4
 
I would use one of the following to set the controls alignment
ctl.Properties.TextAlign = 2
txtPara11.TextAlign = 2
ctl.Properties("TextAlign") = 2

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
 
Back
Top