473,770 Members | 2,133 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.OptionValu e = 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 27813
<Tr********@gma il.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.OptionValu e = 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.chkMyCheckBo x then
'stuff
Endif

or

If Me.chkMyCheckBo x = True then
'stuff
Endif

or

If Me.chkMyCheckBo x.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!NameOfOption Group
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******@pcdata sheet.com
www.pcdatasheet.com
<Tr********@gma il.com> wrote in message
news:11******** **************@ l41g2000cwc.goo glegroups.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.OptionValu e = 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
5184
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 Mozilla to standards compliance mode as I can confirm myself. How can I check whether IE6 and Opera do so too? TIA Regards Xavier van Unen.
8
1750
by: BigMan | last post by:
Are these two lines equivalent? #ifdef MACRO #if MACRO==0
9
3465
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', *without* calling window.open? -- Christopher Benson-Manica | I *should* know what I'm talking about - if I ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
4
15072
by: Claire | last post by:
How do I determine whether Im running in debug or release mode from code please. thanks Claire
1
4403
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. Thanks. Art
4
1819
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
10060
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 tries to check an element that doesn't exist I get this error: document.getElementById("pref" + i) has no properties
2
7026
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
2119
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 time. Is there any simple way to do this without using manual pattern matching? Thanks. -- Nathan Sokalski njsokalski@hotmail.com http://www.nathansokalski.com/
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10260
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9906
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7456
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6712
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.