How can I code a checkbox to use "Y" and "N"?

  • Thread starter Maury Markowitz
  • Start date
M

Maury Markowitz

I have a database that holds a boolean-like value as a "1" or an
"0" (or null, which is "0") in an int field. When I bind this to a
checkbox in the display, changing it to the1 state gives me an error
that the value is invalid. It appears that checkboxes can only use -1
and 0 (and null). Oddly, the checkbox displays the 1's and 0's
properly - 1's come out as "on" and 0's as "off".

Is there a way to do this? I tried hooking event handlers into Before
and AfterUpdate, onClick and even MouseDown. Most of these fired after
the error was popped up, so they didn't help. MouseDown did work, but
when I changed the value in the code (Me!theCheck = -1) it didn't seem
to actually change anything.

Maury
 
K

Klatuu

Why not just use a Boolean field? Displaying the value is not an issue, but
updating it will be.

For example if your control source were
[YesOrNo]
you could then use
=[YesOrNo] * -1
Which would change the 1 to -1 and not change a 0, so it would display
correctly, but it would then not be an updatable control.

Another solution (without changing the data type) would be to use an option
group control. You can use check boxes in option groups, but it would take
two instead of 1.
 
M

Maury Markowitz

Why not just use a Boolean field?  Displaying the value is not an issue, but
updating it will be.

That's the problem, this is a user control that means "is active" and
is used to interactively turn lines on or off in other reports.
Another solution (without changing the data type) would be to use an option
group control. You can use check boxes in option groups, but it would take
two instead of 1.

So you mean to use two check boxes, one as a "1" and another as a "0"?
Hmmmm. Doable, but ugly.

Maury
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top