How to display a Checkbox for a field

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
 
T

Tom Ellison

Dear Ryan:

How about:

CBool(LastAction IS NOT NULL)

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

Tom Ellison
 
S

Sylvain Lafontaine

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.
 
R

Ryan Langton

What about this tells it to display as a check box though? Won't it still
display as a 1 or 0?
 
R

Ryan Langton

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
 

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