>> Text Align

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi, Access 2002.

I want to use the same report for 2 sets of data. One set is text, the other
is numeric. What I want is the ability to align the text at report time.

I have tried the report_open event and the detail1_print. I get the error:

"Object doesn't support this property or method"

on the line:

ctl.TextAlign = cRightAlign

fyi cRightAlign=3

Any ideas or recommendations appreciated :-)

Many thanks,
Jonathan
 
This worked for me. I place a text box (txtCount) in the detail section with
a running sum to get values 1, 2, 3,....

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Me.txtCount Mod 2 = 1 Then
Me.FirstName.TextAlign = 1
Else
Me.FirstName.TextAlign = 3
End If
End Sub
 
Since the code the poster used had "ctl" as the control reference, I suspect
the poster was looping through the controls collection and try to set
TextAlign for all controls. Not all controls have a TextAlign property and
therefore the error message.

I think we need to see more of the code.
 
Thanks for staying with this.... the lines of code are:
**** code start ****
Dim ctl As Access.control
Const cLeftAlign As Byte = 1
Const cRightAlign As Byte = 3

'For Bus numbers have data right aligned
If CInt(Me.OpenArgs) = cRightAlign Then
For Each ctl In Me.Section(0).Controls
'Check whether is a data line control
If Left(LCase(ctl.Name), 4) = "line" Then
ctl.TextAlign = cRightAlign
End If
DoEvents
Next ctl
End If

*** Code End ***
The Textboxes (and 'yes', after John's observation I have checked the
control type :-) ) names each begin with 'line'.

Many thanks
Jonathan
 
Hi Duane, sorry about the confusion. In fact is was still not working until
your post prompted to look at my code again...

<blush>It was absence of good naming convention</blush>

The code was falling over when it hit a real line control!

Thanks, Jonathan
 
Back
Top