how can I make yes no option button required?

D

deensl

I have a user form that prompts a user to click yes no option buttons. This
form fills out a word document replacing the un-checkedboxes with a windings
character that looks like a checked box.
The user form has several frames with 1 set of yes no option buttons in each
frame for each question.
The form works but, I would like to make the user required to answer yes or
no to each question.
I would really appreciate any help on this..

See my code below.

Dim OBYes1 As Bookmark
Dim OBNo1 As Bookmark

'App Option Button 1 Yes
If UserQues1.OBYes1 = True Then
Selection.GoTo What:=wdGoToBookmark, Name:="OBYES1"
Selection.Find.ClearFormatting
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.InsertSymbol Font:="Wingdings", CharacterNumber:=-3976,
Unicode _
:=True

End If

'App Option Button 1 No
If UserQues1.OBNo1 = True Then
Selection.GoTo What:=wdGoToBookmark, Name:="OBNO1"
Selection.Find.ClearFormatting
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With

Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.InsertSymbol Font:="Wingdings", CharacterNumber:=-3976,
Unicode _
:=True

End If
 
F

Fumei2 via OfficeKB.com

You can not, directly. All you can do is with whatever procedure that is
going to exit (unload) the userform, put in code that checks each set of
option buttons to see if one has been set. Even then it gets tedious to
build up the information about which one is NOT used, if more than one is not.


It is easy to get a Yes/No re: each Frame. This can be altered in many ways..
 
F

Fumei2 via OfficeKB.com

BTW: what are you doing with this????

Selection.Find.ClearFormatting
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With

You do not Execute the Find. So it essentially pointless.

Next, do you need to really Select the bookmark?
You can not, directly. All you can do is with whatever procedure that is
going to exit (unload) the userform, put in code that checks each set of
option buttons to see if one has been set. Even then it gets tedious to
build up the information about which one is NOT used, if more than one is not.

It is easy to get a Yes/No re: each Frame. This can be altered in many ways..
.

Sub OuttaHere_Click()
Dim bolNope As Boolean
If fraYadda1.OptYes = False AND _
fraYadda1.OptNo = False Then
bolNope = True
End If

If fraBlah1.OptYes = False AND _
fraBlah1.OptNo = False Then
bolNope = True
End If

If fraWhatever1.OptYes = False AND _
fraWhatever1.OptNo = False Then
bolNope = True
End If

etc.

If bolNope = True Then
Msgbox "One of the questions is not answered."
Exit Sub
End If

As you can see, it simply checks to see if ANY Frame has neither option set.
It does not tell you which one, nor if more than one is missing. In the
above, if fraYadda is missing, AND fraWhatever is missing, you get the error
message. Further, there is no focus back to the missing frame. So, suppose
you DO answer fraYadda, but overlooked fraWhatever...you get the error again.

Can you do it so you find out which one(s) are missing. Yes. Can you put
focus back to the offending control? Yes.

It just takes a lot more fussing with the logic. The coding is simple, the
logic is not.
I have a user form that prompts a user to click yes no option buttons. This
form fills out a word document replacing the un-checkedboxes with a windings
[quoted text clipped - 58 lines]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Loop until end 1
Select Text to End of Footnote 9
If not found ignore 2
Bug 12
help with macro please 1
What is needed to function probaly 2
Error in simple macro 3
Worked in 2003, not in 2007 6

Top