Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2015

    Question Unanswered: Renaming Control On Report From VBA Code

    Hi All...

    I have hit a bit of a roadblock... I have a report that has close to the control limit in Access, I need to rename 450 boxes on the report. 50 Rows of 9 Boxes, at the beginning of each row is a textbox named "trd1, trd2, trd3, etc". I am trying to write code that will find for example trd1, and then any rectangle on that line gets renamed bx1, bx2, through 9 using the control's top value. Perhaps I am making it more difficult than it needs to be... Pasting my code here if anyone can see where I am missing something The code below works on the first row only...

    Thank You

    Sub RenameStuff()
    Dim ctl As Control
    Dim ctl2 As Control
    Dim xi As Integer
    Dim rowcount As Integer
    Dim boxcount As Integer
    Dim rowd(50) As Double
    DoCmd.OpenReport "Process Audit Sheet", acDesign, , , acHidden
    For Each ctl In Reports![Process Audit Sheet]
    Select Case ctl.ControlType
    Case Is = acTextBox:
    For xi = 1 To 50
    If ctl.Name = "trd" & xi Then
    rowd(xi) = ctl.Top
    End If
    Next xi
    End Select
    Next ctl
    boxcount = 0
    For rowcount = 1 To 50
    For Each ctl2 In Reports![Process Audit Sheet]
    Select Case ctl2.ControlType
    Case Is = acRectangle:
    If ctl2.Top = rowd(rowcount) Then
    boxcount = boxcount + 1
    ctl2.Name = "bx" & boxcount
    End If
    End Select
    Next ctl2
    Next rowcount
    DoCmd.Close acReport, "Process Audit Sheet", acSaveYes
    End Sub

  2. #2
    Join Date
    Feb 2015

    Got it :)

    Thanks For Looking The code was fine, it was an oversight on my current control names before execution...

Posting Permissions

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