I'm sure I'm being a bit thick here but can't for the life of me see why this run-time error is occurring. Here's the code:
Public Sub fRTWIni()
Dim varList As Variant
Dim intR As Integer
Dim con As Control
varList = fGetList("ct_adt_RTWYesNo", "ORDER BY RTWYesNo ASC")
For Each con In UF_ReturnToWork.frmRTW.Controls
If TypeName(con) = "ComboBox" And con.Name <> "cbRTWHH" And con.Name <> "cbRTWMM" Then
con.ColumnCount = 2
con.ColumnWidth = 0
For intR = LBound(varList, 2) To UBound(varList, 2)
con.AddItem intR
con.Column(1, intR) = varList(1, intR)
Next intR
End If
Next con
End Sub
The error is occurring on line:
For Each con In UF_ReturnToWork.frmRTW.Controls
UF_ReturnToWork is a userform.
frmRTW is a frame.
I've used this method plenty of times to access the controls with a userform / frame and am absolutely stumped as to why I can't use is now.
As far as I'm aware and from my research, .Controls is a member of the object and therefore I can't understand why it wont allow me to use it.
Any ideas why the error is occurring?
Thanks Gareth
UF_ReturnToWork.frmRTW.Controlsin the watch window to see if it returns a collection of controls, as you'd expect.<Object variable or With block variable not set>. Thanks