I am using MFC to manage Microsoft Access databases usingCDatabase. I support both mdb and accdb formats.
My understanding of BIT fields is:
0 or Null is False or No
-1 is True or Yes
Is this always the case? Values of -1 and 0?
Thanks.
You've got one little mistake:
0 is False/No/Localized equivalent
-1 is True/Yes/Localized equivalent
Null cannot exist in a bit field, but will get displayed as an empty field, or an undefined value in a checkbox (filled with either a square or grey dots)
There should never be any other numbers
Related
I'm working with SSRS Report that display the grades of Students. I need to display the grades which are already rounded to the nearest integer and I'm ok with that. But I'm wondering why the decimal places still appears even if the grades is already rounded and I already set the textbox properties to 0 decimal places. I've notice that it was started when I used cast. What is the problem? I need to cast the grades because of my condition. Please see below sql syntax and images.
I used MSSQL Server 2008 and Report Builder 3.0 r2
Here's my sql syntax in getting the grades of student
,(CASE
when dtl.STUDENT_GRADE < 1 or dtl.STUDENT_GRADE is null Then '-' Else
CAST(dtl.STUDENT_GRADE AS nvarchar(20))end) as GRADE
This is the report looks like and my settings in text box . Please see image
Try setting the Category to "Custom" and then set "Custom format" to N0
I found a solution to my problem, Since the cast gives me an issue with the decimal places, I changed the condition to set the grades of student to 0 if the grades is NULL or less than 1. Then I set the text box properties to show (-) if the value is 0.
Thanks for all your help it gives me an idea to solve my problem.
This is probably a beginner question and I am missing something fundamental, but I appreciate anyone's time and effort.
I have inherited an Access database, where the data is kept in a separate file to the forms and reports.
A report is used to create a letter to summarise a set of results.
The relevant part is in the Detail section of the report, where pairs of Text Box controls are used to show the name of the test, and the result.
The behaviour of the text boxes is that they are hidden (including the name of the test) when the value is zero in the database. However, sometimes we need to include a zero value.
Is this default behaviour?
I have inspected the VBA project and cannot find any logic that is hiding the text boxes.
Other information:
The field is set up as Number (double)
The default value for the field has been made empty, not 0 which seems to be the default.
I have tried using the format property for the control using #;#;0;"" as described here (http://www.experts-exchange.com/questions/21525364/Show-zero-values-as-dashes-on-an-Access-report.html)
I have also tried using ControlSource =IIF([fieldvalue]>0,[fieldvalue],"0") which did show a zero, but the descriptor text box still disappeared, and it was appearing as 0 whether the database field value was 0 or nothing.
Please let me know of any other details that would be helpful.
Thank you everyone for your help.
I hadn't traced back for enough in the logic chain, which #KenWhite's answer gave me the hint for.
The issue was in the query underlying the report - the logic for the field had conditional parameters on it, using IIf() and NULL / 0 checks.
I have a SSIS package that I am programming and my script component won't allow null column inputs. I have checked the box to keep nulls in the flat file source component. My program is running well until my script component where I get the error "The column has a null value" (super vague, I know). The column currently throwing the error is an "int" valued column and is used for aggregations in my script.
I could make the null values 0s or to say "NULL" but I'd prefer to just leave them blank.
I am using SQL Server BIDS 2008.
So because SSIS deals with the databases so much and doesn't want to spend a lot of time differentiating between DB NULL and C# NULL, they create boolean properties for each input column in the Buffer with the naming convention (columnname)_IsNull. You can read more about that on MSDN.
So you have to use those buffer columns to determine whether the value is null and then doing whatever you're trying to do with that column in the component.
So something like
if (!Row.MyColumn_IsNull) {
//do something }
else {
//do something else, or nothing, etc.
}
While Kyle's answer is very sufficient, I used a different method that is working just fine. I used the ternary for c#.
Value = Value_IsNull ? True Value : False Value;
Row.rowname = Row.rowname_IsNull ? 0 : Row.rowname;
This changed the value of my null integer columns to 0 if they were null coming into my script. Otherwise, it retained the value.
Is your error occurring in the C# code somewhere? It gets a little maddening at times when you have a database column with the datatype int, and it allows nulls. In C# land you have to use the int? as apposed to int when you need to accept nulls. Otherwise the approaches mentioned already are a good way to go.
I have an access databse (from an opensource project) that's in Access 2000 format.
All text fields, I've looked at, have ALLOWZEROLENGTH set to TRUE and DEFAULT to "" (empty string).
On conversion to Access 97 (using Access 2003) the ALLOWZEROLENGTH is set to FALSE but the DEFAULT stays at empty string.
Bizarrely (it seems to me) I can still add a record to a table without specifying values for many of the text fields without a problem.
However if I modify the table design by adding a field, thereafter if I try to add a record
lots of 'cannot contain zero length string' errors are triggered.
It's like the DEFAULT value properties on the text fields are dormant until then.
Is this a problem with the convertor in Access 2003?
I also tried converting first to 2003 and then back to 97 but the result was the same
Is the best action for me to do to go through the 97 database and set ALLOWZEROLENGTH to TRUE or set the DEFAULT to Null?
The "best action" is to not use the Access 97 database format. Office 97 is no longer actively supported by Microsoft; that has been the case for over nine (9) years now! (ref: here)
However, if you absolutely must use the Access 97 file format for some reason then yes, you probably should just go through the table definitions and adjust the field properties as required.
I am currently working on a report which has data injected into it from a Web Service. This webservice sends it a "double?" permitting null values. In the report it displays the values returned which are later used to sum and average the numbers. My issue is in the expression to display the value (and i can see a similar issue coming up when i work on the calculations but one step at a time...) I am using an IIf statement checking if the value is numeric, if so display the value (converting it to a double) if not display an empty string. When its a numeric value the value displays properly however when its null I am getting the value #ERROR. It seems that the IIf statement evaluates both ends of the IIf statement!!!
Anyhow I have done some research and it seems people suggest to modify the sending code to check if its null and send a 0 instead BUT in my case this wont help (nor will a negative number as it also sends negative numbers). The reason for this not working in my case is that I have to calculate an average using all 0s but not null values. For example...
"100, 0, null" => this should be an average of 50... if that null
where to be converted to 0 it would average 25...
Anyways heres my code...
=IIf(IsNumeric(Fields!Ventas.Value), CDbl(Fields!Ventas.Value), "")
I have also tried with a switch statement and get the same issue...
=Switch(IsNumeric(Fields!Ventas.Value) = False, "", IsNumeric(Fields!Ventas.Value) = True, CDbl(Fields!Ventas.Value))
Also I have tested that the IIf condition is working properly by testing this:
=IIf(IsNumeric(Fields!Ventas.Value), 1, 0)
And that works properly... Anyways any help would be greatly appreciated as I dont know what else to try... below are some links I found regarding my issue but again they recommend sending a 0 instead of null which in my case is useless... And one link suggests using a switch but again that didnt work...
Link #1
Link #2
I just solved this issue heres how it can be done hope this helps someone else with this same problem!!
=IIf(IsNumeric(Fields!Ventas.Value), CDbl(IIf(IsNumeric(Fields!Ventas.Value), Fields!Ventas.Value, 0)), "")
You will have the same issue using expression with possible division by zero, like IIF([B]=0, Nothing, [A]/[B])
I used a simple workaround: IIF([B]=0, Nothing, [A]/IIF([B]=0, 1, [B]))
This error is also registered on the Microsoft Connect, but no answer from MS so far.