473,385 Members | 1,478 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Determining Whether a Check Box is Checked

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
2 27674
<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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

35
by: Dr.Tube | last post by:
Hi there, I have this web site (www.DrTube.com) which has the following DTD: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> which switches...
8
by: BigMan | last post by:
Are these two lines equivalent? #ifdef MACRO #if MACRO==0
9
by: Christopher Benson-Manica | last post by:
I have the following situation: Page A opens a window named 'foo'. Page A then reloads itself. Is there a way for the reloaded Page A to determine whether there is an open window named 'foo',...
4
by: Claire | last post by:
How do I determine whether Im running in debug or release mode from code please. thanks Claire
1
by: Art Krumsee | last post by:
From within a vb.net app can I check to see whether a separate executable process is running? I can see this process in Task Manager but I don't know how to see if it's active from within my code....
4
by: RossettoeCioccolato | last post by:
How do I determine programmatically whether or not the VC8 C/C++ SxS assemblies currently are installed on a system? Regards, Rossetoecioccolato.
4
by: ug26jhw | last post by:
Is there any way to determine whether an element in a document exists. I have some code like this where the variable i changes: if(document.getElementById('pref'+i).innerHTML... When it...
2
ashitpro
by: ashitpro | last post by:
I want to check whether given IP exist in CIDR range.. e.g. IP is 192.168.1.3 CIDR is 192.168.1.0/24 here according to CIDR lower ip is 192.168.1.1 higher ip is 192.168.1.254
4
by: Nathan Sokalski | last post by:
When determining whether a String can be converted to a DateTime, you can use the IsDate() method. However, I would also like to know whether the string is a date, a time, or both a date and a...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.