View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Susan Susan is offline
external usenet poster
 
Posts: 1,117
Default Looping thru sub-level of controls on userform

on this multipage, i have textboxes that i loop thru to make sure
something's in them. Ok, fine.

then i have a bunch of frames. within the frames are option buttons.
i want to make sure one option button is selected in each frame.

in a previous project somebody gave me the code to do this BUT there
were ONLY frames with option buttons, so i just looped through all the
option buttons. i could do it that way again, by labeling option
buttons with tags (some are hidden, only to be used sometimes, and are
not in this looping counting business. this is what i've got so far
but my theory is wrong somehow.........

====================

'make sure an option button is checked in each
'frame that's visible & used

Dim oControl As Control
Dim bControl As Control
Dim i as Integer

i = 0

For Each oControl In Me.Controls
If TypeOf oControl Is msforms.Frame Then
If oControl.Tag = "CountMe" Then
For Each bControl In oControl
If TypeOf bControl Is msforms.OptionButton Then
If bControl Then
i = i + 1
End If
End If
Next bControl
End If
End If
Next oControl

If i < 5 Then 'something's missing
MsgBox "Every frame must have a selected option button!" _
& vbCrLf & _
vbCrLf & _
"Please go back and answer all the questions." _
, vbOKOnly + vbExclamation
Exit Sub
End If
=========================
any ideas on how to make this theory work? or perhaps it wont & i'll
have to tag each option button individually..........
thanks!
susan