Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / February 2008

Tip: Looking for answers? Try searching our database.

Option Buttons

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Office_Novice - 08 Feb 2008 18:40 GMT
I have 8 Option Buttons on a user form. I would like to require 1 to be
selected.
Somthing like

Cmdbutton click()
OptionButton.setfoucus
If optionButton = false then
msgbox " you must select an option button"
End if
End Sub

The troulble is i need to leave 7 not selected and have one of 8 be required
Any help would be great.
Karl E. Peterson - 08 Feb 2008 19:39 GMT
> I have 8 Option Buttons on a user form. I would like to require 1 to be
> selected.
[quoted text clipped - 9 lines]
> The troulble is i need to leave 7 not selected and have one of 8 be required
> Any help would be great.

Lots of ways to approach this.  One way might be to create a module-level flag
variable, and assign a value to it in the Click event for each Option button,
indicating which was the last one selected.  This would provide an easy means to be
sure one had been chosen before the form is dismissed.
Signature

.NET: It's About Trust!
http://vfred.mvps.org

Office_Novice - 09 Feb 2008 16:31 GMT
Thanks for repliing Karl any chance i could get a snippet from you? i am
still pretty new to this.



> > I have 8 Option Buttons on a user form. I would like to require 1 to be
> > selected.
[quoted text clipped - 14 lines]
> indicating which was the last one selected.  This would provide an easy means to be
> sure one had been chosen before the form is dismissed.
Doug Robbins - Word MVP - 10 Feb 2008 06:27 GMT
Put all of the Option Buttons in a Frame to which you give a name, then use
the following in the Command Button Click event, (replacing the[FrameName]
with the name that you assigned to the Frame):

   Dim checked as Boolean
   Dim acontrol as Control
   checked = False
   For i = 1 To 8
       Set acontrol = [FrameName].Controls(i - 1)
       If acontrol.Value = True Then
           checked = True
       End If
   Next i
   If checked = False Then
       MsgBox " you must select an option button"
   End If

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

> Thanks for repliing Karl any chance i could get a snippet from you? i am
> still pretty new to this.
[quoted text clipped - 21 lines]
>> means to be
>> sure one had been chosen before the form is dismissed.
Office_Novice - 11 Feb 2008 13:28 GMT
That was perfect thnks.

> Put all of the Option Buttons in a Frame to which you give a name, then use
> the following in the Command Button Click event, (replacing the[FrameName]
[quoted text clipped - 38 lines]
> >> means to be
> >> sure one had been chosen before the form is dismissed.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.