Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Aug 2001
    Location
    Cape Town, South Africa, South Africa
    Posts
    399
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Set Position of Textbox (Access 2000)

    I want to set the position of a number of text boxes inside a loop. The following code gives an error:

    Private Sub ReportHeader_Format(Cancel As Integer, FormatCount As Integer)

    Dim a As Integer
    Dim NoPeriod As Integer
    Dim PerTextBox As String

    a = 1600

    For NoPeriod = 1 To 12

    PerTextBox = "M" & NoPeriod
    Me.(M&(a)).Left = a
    a = a + 250

    Next NoPeriod

    End Sub

    The textboxes is named M1 M2 TO M12. So I need the syntax to change the textbox name inside the loop.

    Thanks

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Set Position of Textbox (Access 2000)

    In the snippet

    PerTextBox = "M" & NoPeriod
    Me.(M&(a)).Left = a

    why do you use M&(a)? M is not a variable, and a starts at 1600, and you can't refer to a variable control name like that. You probably need

    Me.Controls(PerTextBox)

    since PerTextBox evaluates to M1, M2 etc.

  3. #3
    3 Star Lounger
    Join Date
    Aug 2001
    Location
    Cape Town, South Africa, South Africa
    Posts
    399
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Set Position of Textbox (Access 2000)

    Thanks for the code it works great

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •