Connecting Tech Pros Worldwide Forums | Help | Site Map

Determining Whether a Check Box is Checked

Travis.Box@gmail.com
Guest
 
Posts: n/a
#1: Nov 13 '05
I have an MS Access userform with 16 Check Boxes. Each of the
checkboxes has a different option value, which coincides with the Check
Box name (eg. cb01.OptionValue = 1). At the bottom of the form is a
command button. When the command button is clicked, I need the VBA
scripting to determine which Check Box has been selected, and then
assign a vaule to a string based on which Check Box has been selected.
What I'm having trouble figuring out is what conditional statement to
use in my "Select Case" statement to determine which of the Check Boxes
have been selected.

I've alerady tried using:

Me.CheckBoxName.OptionValue <==This had no effect

Me.CheckBoxName.Checked = true (or False) <==The ".Checked" was not
recognized. Guess I was stuck in a VB.Net frame of mind


Does anyone have any suggestions on what conditional statement i should
use, or what other process I could use to determine which of the Check
Boxes have been checked?


Darryl Kerkeslager
Guest
 
Posts: n/a
#2: Nov 13 '05

re: Determining Whether a Check Box is Checked


<Travis.Box@gmail.com> wrote[color=blue]
>I have an MS Access userform with 16 Check Boxes. Each of the
> checkboxes has a different option value, which coincides with the Check
> Box name (eg. cb01.OptionValue = 1). At the bottom of the form is a
> command button. When the command button is clicked, I need the VBA
> scripting to determine which Check Box has been selected, and then
> assign a vaule to a string based on which Check Box has been selected.
> What I'm having trouble figuring out is what conditional statement to
> use in my "Select Case" statement to determine which of the Check Boxes
> have been selected.
>[/color]
[snip][color=blue]
> Does anyone have any suggestions on what conditional statement i should
> use, or what other process I could use to determine which of the Check
> Boxes have been checked?[/color]


You say that the checkboxes have an OptionValue, so that means they are
inside an OptionGroup frame. If that's not the case, I would suggest that
you put all of the checkboxes inside an option group frame (actually
probably easier to just create a new one). Then, all you will need to do is
check the value of the option frame, and that will return the value of the
checkbox you have selected.

Second, if what you have is only one possible check out of several values, I
would suggest that you use radio buttons instead, since this is more
consistent with the Windows UI. Generally, when you see several checkboxes
grouped together, the user should assume that he can select none, one, or
all.

To check the value of a checkbox outside a frame,

If Me.chkMyCheckBox then
'stuff
Endif

or

If Me.chkMyCheckBox = True then
'stuff
Endif

or

If Me.chkMyCheckBox.Value = True then
'stuff
Endif

If you have several checkboxes in a frame

--
Darryl Kerkeslager


Power corrupts.
Absolute power corrupts absolutely.
Knowledge is power.
See www.adcritic.com/interactive/view.php?id=5927


PC Datasheet
Guest
 
Posts: n/a
#3: Nov 13 '05

re: Determining Whether a Check Box is Checked


You need to refer to the option group; not the individual checkboxes. Click
on the box around all the checkboxes and go to properties to get the name of
the option group.

Select Case Me!NameOfOptionGroup
Case 1
MyString = " xxx "
Case 2
MyString = " yyy "
.......
.......
Case 16
MyString = " zzz "
End Select

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
resource@pcdatasheet.com
www.pcdatasheet.com


<Travis.Box@gmail.com> wrote in message
news:1109985502.648323.178140@l41g2000cwc.googlegr oups.com...[color=blue]
> I have an MS Access userform with 16 Check Boxes. Each of the
> checkboxes has a different option value, which coincides with the Check
> Box name (eg. cb01.OptionValue = 1). At the bottom of the form is a
> command button. When the command button is clicked, I need the VBA
> scripting to determine which Check Box has been selected, and then
> assign a vaule to a string based on which Check Box has been selected.
> What I'm having trouble figuring out is what conditional statement to
> use in my "Select Case" statement to determine which of the Check Boxes
> have been selected.
>
> I've alerady tried using:
>
> Me.CheckBoxName.OptionValue <==This had no effect
>
> Me.CheckBoxName.Checked = true (or False) <==The ".Checked" was not
> recognized. Guess I was stuck in a VB.Net frame of mind
>
>
> Does anyone have any suggestions on what conditional statement i should
> use, or what other process I could use to determine which of the Check
> Boxes have been checked?
>[/color]


Closed Thread