tags:

views:

269

answers:

3

In MS Access 2007 (using Access 2000 format) I am attempting to get a boolean output from a query such that the result is displayed as a checkbox rather than 0 or -1.

When the query is passing along a boolean input, this is working properly. When I attempt to make an evaluation, the result is 0 or -1, but not a TRUE/FALSE checkbox.

I have tried:

SELECT (MyInt > 1) AS MyBoolResult
SELECT CBool(MyInt > 1) AS MyBoolResult
SELECT IIF((MyInt > 1), TRUE, FALSE) AS MyBoolResult
SELECT CBool(IIF((MyInt > 1), TRUE, FALSE)) AS AS MyBoolResult

In each case my result is a 0 or -1, and I cannot get this into a display checkbox down stream in an ASP .Net web page using a GridView.

Is what I want possible? If so, how is it accomplished?

A: 

That's the way it works and I'm unable to produce the results you want. The only way I know is to produce a temporary table.

Knox
+1  A: 

With your query in design view, click in your field expression box, then press Alt+F11 to bring up the property sheet. If you then switch to the Lookup tab, you can see there are only 3 three choices for Display Control: Text Box; List Box; and Combo Box. You can type in Check Box, but it won't be accepted.

So, you can't have a calculated field expression displayed as a check box in the result set from an Access 2007 query.

Update: I may have misinformed you. If you do have a Check Box option for Display Control, choose it. (I don't have that choice available on my system, but I'm second guessing whether my system is normal.)

If you want something displayed other than -1 or 0, you could try entering True/False (or Yes/No) in the Format box on the field's property sheet.

HansUp
Uh, @HansUp, you really need to fire up Access and try this again. CheckBox is, in fact, one of the choices and ListBox is not. Please edit your answer so I can vote it up as the correct answer.
David-W-Fenton
@David, Did you try with Access 2007? I tried before posting, and Check Box is not among the choices for Display Control on a calculated field expression. A2007 SP2
HansUp
I tried both MDB and ACCDB formats with this expression -> lastyear: IIf(Year(startdate)=2008,True,False) <- still Check Box is not among the Display Control options.
HansUp
Ultimately, the value of displaying it as a checkbox is that the Gridview in the ASP .Net web page that will display the data can use a checkbox. Forms will not help me.My Lookup tab "Display Control" has the values: Text Box, List Box, Combo Box.My General tab "Format" has the values: General Number Currency, Euro, Fixed, Standard, Percent, Scientific.Nothing like "Yes/No" or "True/False"
Degan
The format box doesn't display "Yes/No" or "True/False" among the choices, but you can type it in anyway (without the quotes).
HansUp
The format box changes the display in Access (to a literal "Yes", "No", "True, or "False"). I have not been able to get the query to display a check-box, nor the native GridView function (which appears as an integer). If I really need a check box, I guess I will use a template field.
Degan
A: 

Possibly ASP .Net is expecting a +1 as being the true value. Try putting an ABS on the logical expression. Just guessing though.

Tony Toews