Moving Control In VBA

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • BarbQb
    New Member
    • Oct 2010
    • 31

    Moving Control In VBA

    Hi All.

    I have a report that has a lot of different controls on it and only some need to be seen for certain customers.

    I am trying to Move one control based on the position of the one next to it

    Below is my code, but when the debugger pops up it highlights: Me.CustSKU.Left = Me.CXL.Right + 25



    Code:
    Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    
    Dim lngCustID As Long
      
    lngCustID = Forms![AllCust]![Customer]
      
    Select Case lngCustID
        Case 'Customer ID
            Me.CustSKU.Visible = True
            Me.CustSKU_Label.Visible = True
            Me.CustSKU_Label.Left = Me.CustSKU.Left
            Me.CustSKU_Label.Width = Me.CustSKU.Width
    ...
            Me.CustSKU.Left = Me.CXL.Right + 25
            Me.Field1.Left = Me.CustSKU.Right + 75
            Me.Field2.Left = Me.Field1.Right + 75
            Me.Field3.Left = Me.Field2.Right + 75
            Me.Field4.Left = Me.Field3.Right + 75
            Me.Field5.Left = Me.Field4.Right + 75
    ...
    End Select
    End Sub
    Any suggestions would be appreciated.
  • gnawoncents
    New Member
    • May 2010
    • 214

    #2
    I could be wrong, but I don't think there is a ".right" in VBA. Instead try:

    Code:
    Me.CustSKU.Left = Me.CXL.Left + me.CXL.Width + 25

    Comment

    • BarbQb
      New Member
      • Oct 2010
      • 31

      #3
      I knew it was going to be something very simple.
      Thanks gnawoncents!

      Comment

      Working...