Here I'm just referencing the list box (ComboBox) directly:
in the ThisDisplay module
Call LoadTapRcv(Me.cmbTapRcv1, 1, 7, 1)
then the subroutine:
Private Sub LoadTapRcv(byval cmbCurr as MSForms.ComboBox, dblStart as double, dblEnd as Double, dblIncr as double)
on error goto proc_exit
Dim dblCurr as double
with cmbCurr
.Clear
for dblcurr = dblstart to dblend step dblIncr
.AddItem dblcurr
next dblcurr
.ListRows = .Listcount
end with
Proc_Exit:
exit sub
end sub
Another one, finding elements by name to load the list:
Dim elmCurr As DisplayClient.Element
Dim arrReasons As Variant
Dim intRow As Integer
Dim intCol As Integer
arrReasons = Array(" ", "Tap", "Burn", "Matte", "Cleaning", _
"Running", "Spill", "Vent", "Crane", "Slag")
For intRow = 1 To DispTapRows
For intCol = 1 To 3
Set elmCurr = Me.FindElement("cmbReason" & Format(intRow, "00") & CStr(intCol))
Call LoadDelayReason(elmCurr, arrReasons, intRow, intCol)
Next intCol
Next intRow
The loaddelayreason routine is just a variant on the first one. With the consistently named objects on the display, I can easily loop through and change all the controls I want. I misremembered my code, I ended up referencing all elements directly. I did have a recursive module to find the element, didn't need it:
Public Function GetElement(ByVal elmBase As DisplayClient.Elements, ByVal strCtl As String) As DisplayClient.Element
Dim elmCurr As Object
For Each elmCurr In elmBase
If TypeName(elmCurr) = "IGroup" Then
Set GetElement = GetElement(elmCurr.Elements, strCtl)
Else
If elmCurr.Name = strCtl Then
Set GetElement = elmCurr
End If
End If
If Not GetElement Is Nothing Then
Exit For
End If
Next elmCurr
End Function
You would call it as:
Set elmNeeded = GetElement(ThisDisplay.Elements, "lstMyList")
and it would return the lstMyList object into elmNeeded.