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

How to get value of Toggle/Check/Combo controls?

P: n/a
Basic question about checking the value of
Toggle/Check/Combo/OptionGroups....

Checking like this:

If Me!chkCheckBox Then
...
End If

and like this:

If Not Me!tglToggleButton then
...
End If

causes problems when the value is Null.

Is it worthwhile to do something like this:

If CBool(Nz(Me!tglToggleButton.Value)) Then
...
End If

Or is that not really necessary? Needed only for toggle controls? Should
the ".Value" always be used?

Thanks in advance.

Jan 28 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
"deko" <de**@nospam.com> wrote in
news:z-********************@comcast.com:
Basic question about checking the value of
Toggle/Check/Combo/OptionGroups....

Checking like this:

If Me!chkCheckBox Then
...
End If

and like this:

If Not Me!tglToggleButton then
...
End If

causes problems when the value is Null.

Is it worthwhile to do something like this:

If CBool(Nz(Me!tglToggleButton.Value)) Then
...
End If

Or is that not really necessary? Needed only for toggle
controls? Should the ".Value" always be used?

Thanks in advance.


Checkboxes bound to a table cannot be null. Unbound checkboxes
can be set as to not allow null. If you really need to test for
null on a checkbox,

Select case (me.textbox)
case true
case false
case else
end select

The same for option boxes.

As to using the .value, there is a documented bug in '97 where
Access sometimes (very rarely) misinterprets a straight
me.checkbox and prevents closing of Access. Embedding it in ()
or adding the .value prevents this.

--
Bob Quintal

PA is y I've altered my email address.
Jan 28 '06 #2

P: n/a
"deko" <de**@nospam.com> wrote in
news:z-********************@comcast.com:
Basic question about checking the value of
Toggle/Check/Combo/OptionGroups....


If the toggles/checkboxes are members of an option group, you never
check their individual values. In an Option Group, of course, only
item can be selected at a time, and the value of the selected item
sets the value of the parent option group.

Other than that, checking the value should be just like checking the
value of any control -- it's the default property of the control.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Jan 28 '06 #3

P: n/a
> Other than that, checking the value should be just like checking the
value of any control -- it's the default property of the control.


Default value... I think that's the issue I was having.

With a ToggleButton (unlike a CheckBox) there's no visual indicator that the
control's value is Null. If the default value of a ToggleButton is not set,
the button looks like it should when the form first opens - but the value is
Null, not 0. Only after the user selects and deselects the toggle does the
value become 0. This makes testing with an If statement unreliable - unless
Nz is used. So I need to either set the default value or use Nz when
testing. But there's no reason to use .Value or explicitly convert to
Boolean.

Jan 28 '06 #4

P: n/a
"deko" <de**@nospam.com> wrote in
news:cN******************************@comcast.com:
Other than that, checking the value should be just like checking
the value of any control -- it's the default property of the
control.
Default value... I think that's the issue I was having.


Eh? The "default value" is completely different from the value being
the default property. ctl.Value is not the same as ctl.DefaultValue.

However, ctl and ctl.Value return exactly the same thing, since
..Value is the default property of a control.
With a ToggleButton (unlike a CheckBox) there's no visual
indicator that the control's value is Null. . . .
Are we talking about a toggle button in an option group, or a
standalone toggle button?
. . . If the default value of a ToggleButton is not set,
the button looks like it should when the form first opens - but
the value is Null, not 0. Only after the user selects and
deselects the toggle does the value become 0. This makes testing
with an If statement unreliable - unless Nz is used. So I need to
either set the default value or use Nz when testing. But there's
no reason to use .Value or explicitly convert to Boolean.


Why would you ever *not* have a default value for such a control, or
set the value in the form's OnLoad event?

Seems to me you're having a problem that you shouldn't be having,
since you should be handling the exact same situation with any
control, no matter what it's type. That is, you should always
initialize the values of the controls on your forms.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Jan 29 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.