How to output a boolean from a query - ms-access

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?

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.

I was hoping to comment on HansUp's answer, but that seems to be unavailable...
My own experience in Access 2007 is as per HansUp's original response - the Lookup > Display Control setting only offers me Text Box; List Box; and Combo Box.

I ran into the same problem when creating queries to export Access-Data to JSON. The values ended up as numbers, not as booleans. The only way I could get around this problem programmatically was to have the Javascript part of the import reconvert the data type. A bad hack but I see no other way

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.

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

The only way I found to make MyBoolResult a checkbox is the following:
Create a new (empty) radio button
Change it into a checkbox (by right mouse button and "Change to")
Put MyBoolResult as its Contol Source property

Related

Conditional formatting not working on subform

I have a form in form view with a continuous subform in it.
I have a conditional statement in the conditional formatting for the control in question (which is a combo box) on that continuous subform. This conditional, when evaluates true, disables the combo control for that record:
[Forms]![frmCommuteInSub]![ctlDate]<getStartDate()
I have also tried this statement:
[Forms]![frmCommuteInSub]![ctlDate]<#12/01/2016#
Interestingly, this does not work in the main form... but if I open the subform by itself this formatting works just fine.
Anyone have an idea of what may cause this? I really need this to work in the main form.
PS. I'm using Access 2013. I am proficient in VBA or any other language if that helps.
Try using the DateDiff function and see if that works.
If DateDiff("d",[Forms]![frmCommuteInSub]![ctlDate],getStartDate()) > 1 then
The way I see it you have 2 options, it just depends on which suits you and your project.
Complete the conditional format based on a main form / subform relationship using the expression builder.
Complete the conditional format based using single value evaluation. However, in order to do this you will need to make sure the value you are evaluating is part of the table or more likely query you have the form b
Whichever route you choose, make sure to ensure that the variables or controls you are evaluating are producing correctly formatted results. That's half the battle!
More info:
http://www.iaccessworld.com/conditional-formatting-for-subform-or-datasheet-form/
https://bytes.com/topic/access/insights/868555-demo-conditional-format-subform-unlimited-colours

Show a message to the user instead of blank report [duplicate]

I am building an SSRS 2005 report using BIDS. My report filters on date. When the selected date returns no data rows the report is blank, just the title is displayed, no table or column heading.
How can I change this to display a message like No data available. or Report is empty.?
You could set the property NoRowsMessage available on the report's table control like this:
Select the Tablix control and press F4 to view the Properties pane.
Find the NoRowsMessage property and set the value to whatever message you'd like.
You can also to format the message using the Font and TextAlign properties.
Here are some examples of what the report will look like under various settings:
Further Reading: Here is a Technet article on how to Set a No Data Message for a Data Region
Avoid NoRowsMessage and build your own conditional empty row
One problem (or feature if that's what you want) with NoRowsMessage is that it'll literally replace the entire table with just a plain old message string.
Which provides a relatively counter-intuitive end user experience in my opinion. Normally when no data is found by a system, we'd like to know something about what data was being looked for and what it would have looked like.
Instead, based off how to keep the structure of the Tablix when there is no data to show, you can do the following:
Insert New Header Row, outside the group and above the details record.
Right click on the side of the new row and Set Row Visibility
Set Visibility to the following expression which will count the rows inside the current Tablix and only set Visibility to True if there is no data.
=CountRows() > 0
Optionally, merge the cells and add your own message or just display an empty row
Here's a comparison of how the various options will render: (pick whichever look you think best fits your data and use case)
Right-click on whatever databound element(s) you are using in the report and there should be a property NoDataMessage There are a host of options there but the Caption is the first element I would look at.

SSRS Use 1st Parameter (Multi choice) or 2nd Parameter (Text) for same SQL Parameter

I'm not sure if this is possible, but I would like to use 2x Report Parameters for the same SQL parameter.
Currently I have the following in my WHERE clause which relates to a multi-select drop-down:
and traderid in(#traderid)
But I would like to have something along the lines of:
and (traderid in (#traderid) OR traderid = (#traderid2)
so that users can either type the name that they require as opposed to finding in in the vast drop-down list, or choose multiple traders from the drop-down.
In trying so far, I cannot leave the multi-select blank as SSRS will not run the report and you cannot specify the 'Allow Null option' for multi-select parameters.
Does anyone know if there is a way around this?
You need to add a value to your multiselect parameter that effectively means "Ignore this and use the text box".
For instance, add an option to the multiselect with value -1 and label -Enter Manually-.
In your query, do this:
and (traderid in (#traderid) or (-1 in (#traderid) and traderid = #traderid2))
The above assumes your traderid is integer. If not, adjust accordingly.

Show a Customized Text in the Prompt List

Goal:
Display the text "All State-Province" instead of "All geographies" at the prompt list in SSRS
Problem:
I tried googling around and in the end I don't know how to solve it.
Information:
*Im using SQL server 2012
I don't use Report Server 2012, but in 2008 the following applies.
It depends on how you're populating your parameter,
If you're declaring the values in a list
Right click on the parameter, and change the label text.
or.....
If you're populating from a query then you need to ensure that the value you're using to populate the label returns "All State-Province" instead of "All geographies".
One way round this would be to set up a calculated field on the query used to populate the dataset
something like
=iif(Fields!LabelText.Value="All geographies","All State-Province",Fields!LabelText.Value)
Then use that field as the label.
I see your update..
What I believe you need to do, is set up a new calculated field on your GeographyStateProvince dataset
Call it NewLabelText.
Then use the expression
=iif(Trim(Ucase(Fields!ParameterCaptionIndented.Value))="ALL GEOGRAPHIES","All State-Province",Fields!ParameterCaptionIndented.Value)
Then as shown in my previous screen print, use the new calculated field instead of ParameterCaptionIndented
You can see your datasets on the left of this picture.

Access 2007 option group on report

I'm new to Access so please consider this when forming your response. This has been driving me crazy and I've looked high and low on the 'net for a solution. I look forward to your response.
I have a form with an option group. I've wish to have this display on my report. Take for instance this "test" scenario:
Options
a, b, c
I've created a field in my table to accept the data from the form. In my table, I see 1, 2, 3 when I save a record. Good enough. Now, in my report, I have checkboxes representing options a, b, and c. I wish to have a checkmark within the box corresponding to the option selected on the form.
There's no technical limitation preventing you from displaying output on a report using an Option Group and check boxes.
In the design view of the report, add an option group control from the controls toolbox.
Add 3 checkbox controls to the option group control. When you select the check box control and hover the pointer over the option group, it will change color to indicate that the check box will become a part of the group when placed.
I added three check boxes to an option group on a report and they defaulted to values of 1, 2, and 3, so this should go pretty easily for what you're trying to do.
In the Property Sheet with the option group selected, make sure the Control Source property is set to the column with the 1, 2, 3 value in the underlying data source.
You might want to set the border style to hide the box around the checkboxes and also delete the label control that is automatically generated for the option group. I'm not sure what kind of look you're going for, but I'm sure you can handle the formatting details.
An option group is a user interface object, and UI objects don't belong on reports.
Your data field stores digits, but each of those digits has a meaning. On a report, you want the meaningful data displayed. That means that you need a data table that maps 1, 2 and 3 to something, and then join that table to the field you're storing the option group value in.
Another approach would be to use Switch(), but that means that you'd have to edit the report any time you add another option. A data table makes that a lot easier, as you just add a new record to add a new value.