My guess is that the report and the field to which it is bound are both
called '1stLine'. A field doesn't have a Top property, so you need to
ensure that VBA looks at the control, not at the field with the same name.
Me.Controls("1stLine").Top should work. For example, the following test
code worked for me.
Is that is the digit 1 (one) or the letter l (L) at the start of that
name? If it is the digit, that is not a good idea. A VBA procedure can not
begin with a digit, so if you create an event procedure for this control,
VBA will automatically prepend the letters 'Ctl', e.g. 'Private Sub
Ctl1stLine_AfterUpdate()'. This is a potential source of confusion.
Option Compare Database
Option Explicit
Private StartTop
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Me.CategoryID Mod 2 = 0 Then
Me.Controls("CategoryName").Top = StartTop + 50
Else
Me.Controls("CategoryName").Top = StartTop - 50
End If
End Sub
Private Sub Report_Open(Cancel As Integer)
StartTop = Me.Controls("CategoryName").Top
End Sub
--
Brendan Reynolds (MVP)
bw said:
I'm using code as follows:
If [NumLines] = 5 Then
[1stLine].Top = 0
End If
I'm getting a Compile error:
"Method or Data Member not found."
".Top =" is highlighted
I'm trying to dynamically move controls around the page. Is this the
wrong way to accomplish this?
Thanks for you help,
Bernie