PopupMenus cause NOE in a ControlArray?

I have a segmented control that adds or removes selection option rows:


In the SegmentControl, I either display a new row or remove the current row depending on what the user clicks:

Select Case Index
Case 1
  If SegmentIndex = 0 Then
    wpMain.pmType(2).Enabled = True
    wpMain.pmType.Visible = True
    wpMain.pmSize(2).Enabled = True
    wpMain.pmSize(2).Visible = True
    wpMain.sgAddRemove(2).Enabled = True
    wpMain.sgAddRemove(2).Visible = True
    wpMain.sgAddRemove(2).Enabled = False
  End If
Case 2
  If SegmentIndex = 0 Then
    pmType(3).Enabled = True
    pmType(3).Visible = True
    pmSize(3).Enabled = True
    pmSize(3).Visible = True
    sgAddRemove(3).Enabled = True
    sgAddRemove(3).Visible = True
    sgAddRemove(3).Enabled = False
  End If
Case 3
  If SegmentIndex = 0 Then
    pmType(4).Enabled = True
    pmType(4).Visible = True
    pmSize(4).Enabled = True
    pmSize(4).Visible = True
    sgAddRemove(4).Enabled = True
    sgAddRemove(4).Visible = True
    sgAddRemove(4).Enabled = False
  End If
Case 4
  If SegmentIndex = 1 Then // only option is remove this row
  End If
End Select

Everything looks correct and autocomplete works for the control arrays. However, when I run the code, that first entry for pmType(x).enabled always returns Nil. Also, if I remove the Action event for the SegmentedControl, it works without errors.

This is occurring under 21r1.1 and 19r3.2, so I don’t believe that it is a Web API version issue.


If I change the SegmentedControl to just 2 Buttons, the NOE is resolved and everything is normal.

The plot thickens - in trying to debug the cause of the NOE when accessing my ControlArrays, I simply tried to loop through the Text values of the members. As soon as I tried to access array member 1, I get the NOE. I then tried to get the Ubound for the ControlArray to only step through the existing members - Ubound is not an option …

I know I’ve been living in Visual Studio and XCode for the last 4 months, but, no Ubound on a ControlArray?