By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,851 Members | 1,047 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,851 IT Pros & Developers. It's quick & easy.

Determining Whether a Check Box is Checked

P: n/a
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?

Nov 13 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
<Tr********@gmail.com> wrote
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.
[snip] 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?

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
Nov 13 '05 #2

P: n/a
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
re******@pcdatasheet.com
www.pcdatasheet.com
<Tr********@gmail.com> wrote in message
news:11**********************@l41g2000cwc.googlegr oups.com...
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?

Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.