How to use a CheckBox control

jal

Registered User.
Local time
Today, 00:35
Joined
Mar 30, 2007
Messages
1,709
When I try this VBA code:

If Me.ckBoxSortMgaByLastName.Value = True

the form crashes with an error:

"You entered an expression that has no value."

I get this error whether unchecked or checked. For debugging I tried this code:

MsgBox (Me.ckBoxSortMgaByLastName.Value)

Got the same error msg.

I went into the debugger and typed

? Me.ckBoxSortMgaByLastName.Value

and got the same error message yet again.
 
Try using ..

Code:
Me.ckBoxSortMgaByLastName = True

-dK
 
Try using ..

Code:
Me.ckBoxSortMgaByLastName = True
-dK
My goal here isn't to assign a value but to poll for the current value as selected by the user.

Nonethless I tried your code, and it gives me the error:

"You can't assign a value to this object."
 
Ok, I've about got it working. The problem is that I tend to affiliate the "Option Group" control with the VB.Net "Group Box" control

In the VB.Net version, you can drop a checkbox into the GroupBox without it necessarily behaving like an "option button" - in other words you can use it as a standalone checkbox instead of an option button.

But with VBA, apparently, once you drop the checkbox into an Option Group, its functionality becomes limited to that of an option button. Hence the error messages.

I should have used a Rectangle, I suppose, instead of an Option Group.
 
lol, now you say it's part of an option group. ;)

Glad you have it figured out.

-dK
 
lol, now you say it's part of an option group. ;)

Glad you have it figured out.

-dK

Well, it wasn't supposed to be and therefore I didn't realize it was. This is an easy mistake for a beginner like me to make. What happened is that, a long while back, I dropped an option group on the form. Several versions later it was no longer serving that purpose, and so I forgot it was an option group. I didn't remember until all these failed debugging-efforts triggered my memory.
 
Just messing with ya ...

I've been prone to the same so understand your pain. It takes clever copying and pasting to set one inside of an option group so that it doesn't become part of the option group.

Good luck!
-dK
 
Just messing with ya ...

I've been prone to the same so understand your pain. It takes clever copying and pasting to set one inside of an option group so that it doesn't become part of the option group.

Good luck!
-dK

I vacillated again - and the irony is, now that I want it to function as an option group once again, I simply can't seem get it to do so. Is there a method to this madness, anyone?
 
If it is part of an option group, you need to do your condition based upon the option group.

For instance, the values assigned when you create one is 1, 2, 3 .... (you check the properties of the control to see what it's option value is).

So if it is ... it's more like ...

Code:
If Me.optOptionGroupName = x Then ...

Where x is that option value.

-dK
 
If it is part of an option group, you need to do your condition based upon the option group.

For instance, the values assigned when you create one is 1, 2, 3 .... (you check the properties of the control to see what it's option value is).

So if it is ... it's more like ...

Code:
If Me.optOptionGroupName = x Then ...

Where x is that option value.

-dK
Thanks, but that's wasn't the question I was asking. I had no opportunity to use the logic you are proposing because the checkboxes are behaving like regular checkboxes (not as option buttons). In other words the user can checkmark all 4 of them at once because the option group is behaving like a rectangle, not as an option group.

I found the solution here:

http://office.microsoft.com/en-us/access/HP030718921033.aspx

Apparently, you have to drag each option button off the option group and then paste it back on - if you drag it back on it won't work. Must be a paste.
 

Users who are viewing this thread

Back
Top Bottom