Ann
Mon Jun 16 08:59:00 PDT 2008
I think I understand what you are saying. I used a tutorial from
http://www.fontstuff.com/vba/vbatut09pfv.htm and I guess being a beginner I
just didn't think about using one button. I will the next time though.
Thanks.
This"StevenM" wrote:
> To: Ann,
>
> I'm unsure if I understand your problem, but it seems to me that you have
> (one or) two buttons too many.
>
> Why don't you have just two option buttons, one representing frmGroup1 and
> the other frmGroup2, together in one group? Then if one selected frmGroup1,
> the other button would be deselected automatically, and if one selected
> frmGroup2, then frmGroup1 would be deselected autormatically. And if you
> need a third option, when both frmGroup1 and frmGroup2 are deselected, then
> add a third option button to the group with the caption "None" or "Neither"
> or "Both off" or whatever.
>
> On the other hand, lets say we have 4 option buttons.
> Buttons 1 & 2 form one group, 1 = on & 2 = off;
> Buttons 3 & 4 form another group, 3 = on & 4 = off.
>
> The code you would need would be:
>
> Private Sub OptionButton1_Click()
> Me.OptionButton3.Value = False
> Me.OptionButton4.Value = True
> End Sub
>
> Private Sub OptionButton3_Click()
> Me.OptionButton1.Value = False
> Me.OptionButton2.Value = True
> End Sub
>
> This would allow both groups to be "off" and yet if button1 is selected,
> then button 3 is turned off and button 4 (the "off" button) is turned on.
> Likewise, if button 3 is turned on, button 1 is turned off and button 2 (the
> "off" button) is turned on.
>
> Steven Craig Miller
>
> "Ann" wrote:
>
> > I am just starting to learn VBA and am not sure how to do if statements on
> > option groups if someone can help me. I tried a number of different things
> > but nothing happens.
> >
> > I have a User Form with two option groups. They are:
> >
> > frmGroup1
> > optYes
> > optNo
> >
> > frmGroup2
> > optYes
> > optNo
> >
> > If frmGroup1, optYes is clicked then frmGroup2, has to be optNo otherwise a
> > message needs to appear telling the user it must be No, the entry is canceled
> > and they stay in frmGroup2 so they can click No
> >
> > ElseIf frmGroup1, optNo is clicked and frmGroup2, optYes is clicked (this is
> > not a mandatory Yes option) a message needs to appear telling the user the
> > item needs to be put on hold. Any other Any other options are fine and they
> > can continue on with the form.
> >
> > Thanks in advance for all the help.
>