For Each Statement

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to reset all of my option buttons on a form to FALSE, when the user
clicks a button. I cannot find the syntax for this anywhere. Can you please
give me an example.

Thanks for your help,

-Chris
 
Try this
me.OptionButton1Name=0
me.OptionButton2Name=0
me.OptionButton3Name=0

If the option button are in a group, then assign the value to the group, but
dont put a 0 value in the OptionValue of any of the buttons in that group.
 
I have about 35 option buttons. Is there a way to write a For Each Statement
that would keep me from having to list all of the names of the buttons?

-Chris
 
Looping code might look like this:
Dim ctrl As Control
For Each ctrl In Me.Controls
If TypeOf ctrl Is OptionButton Then
ctrl = False
End If
Next
 
Excellent Duane, That worked great.

-Chris

Duane Hookom said:
Looping code might look like this:
Dim ctrl As Control
For Each ctrl In Me.Controls
If TypeOf ctrl Is OptionButton Then
ctrl = False
End If
Next
 
I usually write

if ctrl.controltype=acOptionButton then

How is that different from the TypeOf approach, other than syntactically?
 
Back
Top