How to display a Checkbox for a field

  • Thread starter Thread starter Ryan Langton
  • Start date Start date
R

Ryan Langton

I have a view I'm creating that is somewhat of a summary view. The Bit
field it has no problem displaying as a checkbox, that's the way I have it
defined in the Table. However, what about displaying Checkboxes for other
fields? For example, I have a field called LastAction. If the LastAction
field is Not Null I want the checkbox to be checked, if it IS Null, I want
the checkbox unchecked. Here's the portion of my T-SQL statement that
pertains to this "LastAction" field:

CASE WHEN LastAction IS NULL
THEN 0 ELSE 1 END AS Actions

Now this displays 0 or 1 depending on whether the Actions field contains
data. Is there anyway to make it display a checkbox instead (Checked for 1,
Unchecked for 0)

Thanks,
Ryan
 
Dear Ryan:

How about:

CBool(LastAction IS NOT NULL)

A column must be explicitly boolean to display with a check box.

Tom Ellison
 
You can try to convert the result to a Bit field using the Convert() or the
Cast() functions on the result of the Case statement.
 
What about this tells it to display as a check box though? Won't it still
display as a 1 or 0?
 
I tried CAST( <CASE STATEMENT> AS BIT) AS Actions
Now it displays as either True or False. Is there any way to tell it to use
a checkbox?

Thanks,
Ryan
 
Back
Top