PC Review


Reply
Thread Tools Rate Thread

Check if a optionbutton is selected

 
 
Gert-Jan
Guest
Posts: n/a
 
      21st Dec 2006
Hi,

In a userform I use three optionbuttons. One of them must be selected by the
user. How can let VBA check if this is done?

Regards, Gert-Jan


 
Reply With Quote
 
 
 
 
Gert-Jan
Guest
Posts: n/a
 
      21st Dec 2006
Hi Martin,

Thanks, but I know what I have to do. Isn't there a way to do this simple
and fast (not depending on the number of optionbuttons)?

Gert-Jan

"Martin Fishlock" <(E-Mail Removed)> schreef in bericht
news:85E710C4-79B5-4485-BCFB-(E-Mail Removed)...
> Hi,
>
> You need to check each of the buttons for true.
>
> Another way is to seta default for button1 to true in the form design (or
> at
> initialization).
>
> --
> Hope this helps
> Martin Fishlock, Bangkok, Thailand
> Please do not forget to rate this reply.
>
>
> "Gert-Jan" wrote:
>
>> Hi,
>>
>> In a userform I use three optionbuttons. One of them must be selected by
>> the
>> user. How can let VBA check if this is done?
>>
>> Regards, Gert-Jan
>>
>>
>>



 
Reply With Quote
 
Gary Keramidas
Guest
Posts: n/a
 
      22nd Dec 2006
maybe something like this, change userform1 to your userform name

Dim optionbuttom As Control
For Each OptionButton In UserForm1.Controls
If OptionButton.Value = True Then
MsgBox OptionButton.Caption & " = True"
End If
Next

--


Gary


"Gert-Jan" <(E-Mail Removed)> wrote in message
news:458b1a36$0$17958$(E-Mail Removed)...
> Hi Martin,
>
> Thanks, but I know what I have to do. Isn't there a way to do this simple and
> fast (not depending on the number of optionbuttons)?
>
> Gert-Jan
>
> "Martin Fishlock" <(E-Mail Removed)> schreef in bericht
> news:85E710C4-79B5-4485-BCFB-(E-Mail Removed)...
>> Hi,
>>
>> You need to check each of the buttons for true.
>>
>> Another way is to seta default for button1 to true in the form design (or at
>> initialization).
>>
>> --
>> Hope this helps
>> Martin Fishlock, Bangkok, Thailand
>> Please do not forget to rate this reply.
>>
>>
>> "Gert-Jan" wrote:
>>
>>> Hi,
>>>
>>> In a userform I use three optionbuttons. One of them must be selected by the
>>> user. How can let VBA check if this is done?
>>>
>>> Regards, Gert-Jan
>>>
>>>
>>>

>
>



 
Reply With Quote
 
Gary Keramidas
Guest
Posts: n/a
 
      22nd Dec 2006
sorry, there is a typo in the first line:
Dim Optionbutton As Control


--


Gary


"Gary Keramidas" <GKeramidasATmsn.com> wrote in message
news:(E-Mail Removed)...
> maybe something like this, change userform1 to your userform name
>
> Dim optionbuttom As Control
> For Each OptionButton In UserForm1.Controls
> If OptionButton.Value = True Then
> MsgBox OptionButton.Caption & " = True"
> End If
> Next
>
> --
>
>
> Gary
>
>
> "Gert-Jan" <(E-Mail Removed)> wrote in message
> news:458b1a36$0$17958$(E-Mail Removed)...
>> Hi Martin,
>>
>> Thanks, but I know what I have to do. Isn't there a way to do this simple and
>> fast (not depending on the number of optionbuttons)?
>>
>> Gert-Jan
>>
>> "Martin Fishlock" <(E-Mail Removed)> schreef in bericht
>> news:85E710C4-79B5-4485-BCFB-(E-Mail Removed)...
>>> Hi,
>>>
>>> You need to check each of the buttons for true.
>>>
>>> Another way is to seta default for button1 to true in the form design (or at
>>> initialization).
>>>
>>> --
>>> Hope this helps
>>> Martin Fishlock, Bangkok, Thailand
>>> Please do not forget to rate this reply.
>>>
>>>
>>> "Gert-Jan" wrote:
>>>
>>>> Hi,
>>>>
>>>> In a userform I use three optionbuttons. One of them must be selected by
>>>> the
>>>> user. How can let VBA check if this is done?
>>>>
>>>> Regards, Gert-Jan
>>>>
>>>>
>>>>

>>
>>

>
>



 
Reply With Quote
 
=?Utf-8?B?TWFydGluIEZpc2hsb2Nr?=
Guest
Posts: n/a
 
      22nd Dec 2006
I don't believe that the group or frame properties allow for the
identificaiton of the option button that is true.

The solution is to write a generic function that returns the name to the
optionbutton that is true in a group.

Not much help.
--
Hope this helps
Martin Fishlock, Bangkok, Thailand
Please do not forget to rate this reply.


"Gert-Jan" wrote:

> Hi Martin,
>
> Thanks, but I know what I have to do. Isn't there a way to do this simple
> and fast (not depending on the number of optionbuttons)?
>
> Gert-Jan
>
> "Martin Fishlock" <(E-Mail Removed)> schreef in bericht
> news:85E710C4-79B5-4485-BCFB-(E-Mail Removed)...
> > Hi,
> >
> > You need to check each of the buttons for true.
> >
> > Another way is to seta default for button1 to true in the form design (or
> > at
> > initialization).
> >
> > --
> > Hope this helps
> > Martin Fishlock, Bangkok, Thailand
> > Please do not forget to rate this reply.
> >
> >
> > "Gert-Jan" wrote:
> >
> >> Hi,
> >>
> >> In a userform I use three optionbuttons. One of them must be selected by
> >> the
> >> user. How can let VBA check if this is done?
> >>
> >> Regards, Gert-Jan
> >>
> >>
> >>

>
>
>

 
Reply With Quote
 
Gert-Jan
Guest
Posts: n/a
 
      22nd Dec 2006
I see what you want to do, but this is not what I want (and it also doesn't
work). In my userform I have three option buttons. Final operation: check if
one of the optionbuttons is clicked. If not: msgbox "please select an option
first"

Gert-Jan

"Gary Keramidas" <GKeramidasATmsn.com> schreef in bericht
news:(E-Mail Removed)...
> maybe something like this, change userform1 to your userform name
>
> Dim optionbuttom As Control
> For Each OptionButton In UserForm1.Controls
> If OptionButton.Value = True Then
> MsgBox OptionButton.Caption & " = True"
> End If
> Next
>
> --
>
>
> Gary
>
>
> "Gert-Jan" <(E-Mail Removed)> wrote in message
> news:458b1a36$0$17958$(E-Mail Removed)...
>> Hi Martin,
>>
>> Thanks, but I know what I have to do. Isn't there a way to do this simple
>> and fast (not depending on the number of optionbuttons)?
>>
>> Gert-Jan
>>
>> "Martin Fishlock" <(E-Mail Removed)> schreef in
>> bericht news:85E710C4-79B5-4485-BCFB-(E-Mail Removed)...
>>> Hi,
>>>
>>> You need to check each of the buttons for true.
>>>
>>> Another way is to seta default for button1 to true in the form design
>>> (or at
>>> initialization).
>>>
>>> --
>>> Hope this helps
>>> Martin Fishlock, Bangkok, Thailand
>>> Please do not forget to rate this reply.
>>>
>>>
>>> "Gert-Jan" wrote:
>>>
>>>> Hi,
>>>>
>>>> In a userform I use three optionbuttons. One of them must be selected
>>>> by the
>>>> user. How can let VBA check if this is done?
>>>>
>>>> Regards, Gert-Jan
>>>>
>>>>
>>>>

>>
>>

>
>



 
Reply With Quote
 
Gary Keramidas
Guest
Posts: n/a
 
      22nd Dec 2006
if you only have 3 option buttons:

If Me.OptionButton1.Value = False And Me.OptionButton2.Value = False And _
Me.OptionButton3.Value = False Then MsgBox " you must select an option
button"


--


Gary


"Gert-Jan" <(E-Mail Removed)> wrote in message
news:458b2495$0$23134$(E-Mail Removed)...
>I see what you want to do, but this is not what I want (and it also doesn't
>work). In my userform I have three option buttons. Final operation: check if
>one of the optionbuttons is clicked. If not: msgbox "please select an option
>first"
>
> Gert-Jan
>
> "Gary Keramidas" <GKeramidasATmsn.com> schreef in bericht
> news:(E-Mail Removed)...
>> maybe something like this, change userform1 to your userform name
>>
>> Dim optionbuttom As Control
>> For Each OptionButton In UserForm1.Controls
>> If OptionButton.Value = True Then
>> MsgBox OptionButton.Caption & " = True"
>> End If
>> Next
>>
>> --
>>
>>
>> Gary
>>
>>
>> "Gert-Jan" <(E-Mail Removed)> wrote in message
>> news:458b1a36$0$17958$(E-Mail Removed)...
>>> Hi Martin,
>>>
>>> Thanks, but I know what I have to do. Isn't there a way to do this simple
>>> and fast (not depending on the number of optionbuttons)?
>>>
>>> Gert-Jan
>>>
>>> "Martin Fishlock" <(E-Mail Removed)> schreef in bericht
>>> news:85E710C4-79B5-4485-BCFB-(E-Mail Removed)...
>>>> Hi,
>>>>
>>>> You need to check each of the buttons for true.
>>>>
>>>> Another way is to seta default for button1 to true in the form design (or
>>>> at
>>>> initialization).
>>>>
>>>> --
>>>> Hope this helps
>>>> Martin Fishlock, Bangkok, Thailand
>>>> Please do not forget to rate this reply.
>>>>
>>>>
>>>> "Gert-Jan" wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> In a userform I use three optionbuttons. One of them must be selected by
>>>>> the
>>>>> user. How can let VBA check if this is done?
>>>>>
>>>>> Regards, Gert-Jan
>>>>>
>>>>>
>>>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
Tom Ogilvy
Guest
Posts: n/a
 
      22nd Dec 2006
if OptionButton1.Value or OptionButton2.Value or _
OptionButton3.Value then
' one button is selected
else
msgbox "please select an option first"
end if


--
Regards
Tom Ogilvy

"Gert-Jan" <(E-Mail Removed)> wrote in message
news:458b2495$0$23134$(E-Mail Removed)...
>I see what you want to do, but this is not what I want (and it also doesn't
>work). In my userform I have three option buttons. Final operation: check
>if one of the optionbuttons is clicked. If not: msgbox "please select an
>option first"
>
> Gert-Jan
>
> "Gary Keramidas" <GKeramidasATmsn.com> schreef in bericht
> news:(E-Mail Removed)...
>> maybe something like this, change userform1 to your userform name
>>
>> Dim optionbuttom As Control
>> For Each OptionButton In UserForm1.Controls
>> If OptionButton.Value = True Then
>> MsgBox OptionButton.Caption & " = True"
>> End If
>> Next
>>
>> --
>>
>>
>> Gary
>>
>>
>> "Gert-Jan" <(E-Mail Removed)> wrote in message
>> news:458b1a36$0$17958$(E-Mail Removed)...
>>> Hi Martin,
>>>
>>> Thanks, but I know what I have to do. Isn't there a way to do this
>>> simple and fast (not depending on the number of optionbuttons)?
>>>
>>> Gert-Jan
>>>
>>> "Martin Fishlock" <(E-Mail Removed)> schreef in
>>> bericht news:85E710C4-79B5-4485-BCFB-(E-Mail Removed)...
>>>> Hi,
>>>>
>>>> You need to check each of the buttons for true.
>>>>
>>>> Another way is to seta default for button1 to true in the form design
>>>> (or at
>>>> initialization).
>>>>
>>>> --
>>>> Hope this helps
>>>> Martin Fishlock, Bangkok, Thailand
>>>> Please do not forget to rate this reply.
>>>>
>>>>
>>>> "Gert-Jan" wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> In a userform I use three optionbuttons. One of them must be selected
>>>>> by the
>>>>> user. How can let VBA check if this is done?
>>>>>
>>>>> Regards, Gert-Jan
>>>>>
>>>>>
>>>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
Gert-Jan
Guest
Posts: n/a
 
      22nd Dec 2006
Thanks, this works fine for this moment.

Gert-Jan

"Gary Keramidas" <GKeramidasATmsn.com> schreef in bericht
news:(E-Mail Removed)...
> if you only have 3 option buttons:
>
> If Me.OptionButton1.Value = False And Me.OptionButton2.Value = False And _
> Me.OptionButton3.Value = False Then MsgBox " you must select an option
> button"
>
>
> --
>
>
> Gary
>
>
> "Gert-Jan" <(E-Mail Removed)> wrote in message
> news:458b2495$0$23134$(E-Mail Removed)...
>>I see what you want to do, but this is not what I want (and it also
>>doesn't work). In my userform I have three option buttons. Final
>>operation: check if one of the optionbuttons is clicked. If not: msgbox
>>"please select an option first"
>>
>> Gert-Jan
>>
>> "Gary Keramidas" <GKeramidasATmsn.com> schreef in bericht
>> news:(E-Mail Removed)...
>>> maybe something like this, change userform1 to your userform name
>>>
>>> Dim optionbuttom As Control
>>> For Each OptionButton In UserForm1.Controls
>>> If OptionButton.Value = True Then
>>> MsgBox OptionButton.Caption & " = True"
>>> End If
>>> Next
>>>
>>> --
>>>
>>>
>>> Gary
>>>
>>>
>>> "Gert-Jan" <(E-Mail Removed)> wrote in message
>>> news:458b1a36$0$17958$(E-Mail Removed)...
>>>> Hi Martin,
>>>>
>>>> Thanks, but I know what I have to do. Isn't there a way to do this
>>>> simple and fast (not depending on the number of optionbuttons)?
>>>>
>>>> Gert-Jan
>>>>
>>>> "Martin Fishlock" <(E-Mail Removed)> schreef in
>>>> bericht news:85E710C4-79B5-4485-BCFB-(E-Mail Removed)...
>>>>> Hi,
>>>>>
>>>>> You need to check each of the buttons for true.
>>>>>
>>>>> Another way is to seta default for button1 to true in the form design
>>>>> (or at
>>>>> initialization).
>>>>>
>>>>> --
>>>>> Hope this helps
>>>>> Martin Fishlock, Bangkok, Thailand
>>>>> Please do not forget to rate this reply.
>>>>>
>>>>>
>>>>> "Gert-Jan" wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> In a userform I use three optionbuttons. One of them must be selected
>>>>>> by the
>>>>>> user. How can let VBA check if this is done?
>>>>>>
>>>>>> Regards, Gert-Jan
>>>>>>
>>>>>>
>>>>>>
>>>>
>>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
Gary Keramidas
Guest
Posts: n/a
 
      22nd Dec 2006
or how about something like this? just add your code instead of the message
boxes

Private Sub CommandButton1_Click()
Select Case True
Case Me.OptionButton1
MsgBox "optionbutton1 selected"
Case Me.OptionButton2
MsgBox "optionbutton2 selected"
Case Me.OptionButton3
MsgBox "optionbutton3 selected"
Case Else
MsgBox "no optionbutton selected"
End Select
End Sub



--


Gary


"Gert-Jan" <(E-Mail Removed)> wrote in message
news:458b328d$0$23134$(E-Mail Removed)...
> Thanks, this works fine for this moment.
>
> Gert-Jan
>
> "Gary Keramidas" <GKeramidasATmsn.com> schreef in bericht
> news:(E-Mail Removed)...
>> if you only have 3 option buttons:
>>
>> If Me.OptionButton1.Value = False And Me.OptionButton2.Value = False And _
>> Me.OptionButton3.Value = False Then MsgBox " you must select an option
>> button"
>>
>>
>> --
>>
>>
>> Gary
>>
>>
>> "Gert-Jan" <(E-Mail Removed)> wrote in message
>> news:458b2495$0$23134$(E-Mail Removed)...
>>>I see what you want to do, but this is not what I want (and it also doesn't
>>>work). In my userform I have three option buttons. Final operation: check if
>>>one of the optionbuttons is clicked. If not: msgbox "please select an option
>>>first"
>>>
>>> Gert-Jan
>>>
>>> "Gary Keramidas" <GKeramidasATmsn.com> schreef in bericht
>>> news:(E-Mail Removed)...
>>>> maybe something like this, change userform1 to your userform name
>>>>
>>>> Dim optionbuttom As Control
>>>> For Each OptionButton In UserForm1.Controls
>>>> If OptionButton.Value = True Then
>>>> MsgBox OptionButton.Caption & " = True"
>>>> End If
>>>> Next
>>>>
>>>> --
>>>>
>>>>
>>>> Gary
>>>>
>>>>
>>>> "Gert-Jan" <(E-Mail Removed)> wrote in message
>>>> news:458b1a36$0$17958$(E-Mail Removed)...
>>>>> Hi Martin,
>>>>>
>>>>> Thanks, but I know what I have to do. Isn't there a way to do this simple
>>>>> and fast (not depending on the number of optionbuttons)?
>>>>>
>>>>> Gert-Jan
>>>>>
>>>>> "Martin Fishlock" <(E-Mail Removed)> schreef in bericht
>>>>> news:85E710C4-79B5-4485-BCFB-(E-Mail Removed)...
>>>>>> Hi,
>>>>>>
>>>>>> You need to check each of the buttons for true.
>>>>>>
>>>>>> Another way is to seta default for button1 to true in the form design (or
>>>>>> at
>>>>>> initialization).
>>>>>>
>>>>>> --
>>>>>> Hope this helps
>>>>>> Martin Fishlock, Bangkok, Thailand
>>>>>> Please do not forget to rate this reply.
>>>>>>
>>>>>>
>>>>>> "Gert-Jan" wrote:
>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> In a userform I use three optionbuttons. One of them must be selected by
>>>>>>> the
>>>>>>> user. How can let VBA check if this is done?
>>>>>>>
>>>>>>> Regards, Gert-Jan
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
code to check OptionButton selected within multiple frames porky2j@hotmail.com Microsoft Excel Programming 1 16th Jul 2008 12:59 PM
When Check Box selected... dropdown3 via AccessMonster.com Microsoft Access Forms 6 30th May 2006 02:29 PM
How to allow only one check box to be selected within a set of ch. =?Utf-8?B?Q0M=?= Microsoft Access Forms 2 17th Feb 2005 08:39 PM
How do i check to see if a certain cell is selected? =?Utf-8?B?TWljaGFlbCBK?= Microsoft Access VBA Modules 2 10th Jan 2005 05:13 AM
How to lock a check box once selected Dave Microsoft Access Form Coding 6 23rd Mar 2004 03:11 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:31 AM.