Abintio Record Format- Setting NULL to variable - ab-initio

I have a compoents input record format with a field set to NULL,
like,
record
string(3) INPUT = NULL;
end;
Comp A -----FlowAtoB---------> Comp B
The above record format is the FlowAtoB.
I can understand that this sets the value of INPUT to null. But, In case if i have value for this from previous component A, how this will behave?
I'm not able to understand clearly the use of this from the help document.

It is the default setting for your INPUT.
There is nothing wrong with it.
When component A will send the information to B it will behave just fine, as far as I'm concerned.
Look at this example from my grpah that I'm working right now:
string(30) salesperson = NULL("");
When I send data it works ok.
Try adding the brackets and quotation marks, but I think it was by default there.
Hope this helps

Related

Type Mismatch (Error 13) when populating a null field in VBA

I'm trying to populate a control from an external form with a string value on button click - this is working perfectly when there is already existing text, however if there is nothing then it is treated as a null value and therefore returns a Type Mismatch error.
I thought I would be able to work around this by using:
Nz(Forms!frmSpecifications!boxScratchpad.value, "") = "Text string"
But this hasn't worked.
Could it be to do with how I am calling the control, or the properties of the control itself?
UPDATE: After looking into this a bit more I have pinpointed the issue to a SQL query execution earlier in the code which runs an update statement on the same table that boxScratchpad normally gets its data from (although the field which is fed into boxScratchpad is not actually updated). If I comment out this code so that the update statement doesn't run, boxScratchpad populates successfully. It seems like there could be a conflict between the table being updated and boxScratchpad being assigned a new value within the same code?
First of all, understand what you are trying to accomplish and what your code does.
Assuming your control is a textbox, the property that displays its text is value. If your control is a button, the property that displays text is caption.
You are trying to assign a string to this control value or caption, there will be no issues if those properties are currently NULL.
The mistake lies within the nz. If nz evaluates your control's property to NULL, it will return your empty string as the answer, thus ending in this situation:
"" = "Some text"
Which will throw error "It requires an object".
Remove the nz function.
To really test the interference of your SQL update with the control, use the inmediate window in vba editor to execute and test your code.

Using an expression in a numeric form control

I have an Access form with a textbox bound to a currency field in a table. As expected, anything other than a numerical entry generates an error. Occasionally, users need to enter several amounts and have those added together and the result entered into the currency field.
To accomplish this, I would like users to enter an equal sign followed by a valid arithmetical string which would evaluate to a number exactly as they would in an Excel cell. For example, if a user enters "=5.31+2" I want the field to evaluate to "7.31" and use that as the value passed to the table when the record is updated or saved. The current workaround is to use the Calculator application but that isn't the ideal solution.
I tried the following code and applied it to both the BeforeUpdate and OnLostFocus events of the textbox (named "tbxTotal_Paid") but neither worked. I simply got "The value you entered is not valid for this field" error.
Dim charCt As Integer
Dim evalStr As String
If Left(tbxTotal_Paid, 1) = "=" Then
charCt = Len(tbxTotal_Paid)
evalStr = Right(tbxTotal_Paid, charCt - 1)
Me.tbxTotal_Paid = CCur(evalStr)
End If
Is this simply applying the code to the incorrect event or is this a coding issue? Any assistance is appreciated.
For me your code looks fine but you might put it in the wrong place.
Like you said Acess is giving you this error because the textbox is bound to the currency-field. So it will never accept non-numerical values because the value-checking code fires even before the before_update-event.
I think the best solution would be to hide your bound text box using Me.tbxTotal_Paid.Visible = False and creating a surrogate textbox which is not bound. You put your code in the beforeUpdate-Event or Change-Event of your surrogate. At the end you should check your final result with IsNumeric(). That way your surrogate textbox writes only correct values to your bound hidden textbox and only numbers arrive at your table.
An alternative would be to change the currency column to a string-field but this would not be wise because of potential wrong data in your database.

SQL insert of '' is neither null or empty in Access

I have a function that essentially copies records and inserts them with new IDs. The code works and everything copies fine.
The SQL that occurs is essentially:
INSERT INTO myTable (ID, field, select) VALUES ('newID','stuff','')
Notice the last value is blank,empty,null, whatever. Sometimes it has something in it, sometimes it doesn't.
I have a check against that value in an access form and it uses isNull or isEmpty and both come up false, with only records that are inserted in this manner.
So what is being inserted, if nothing is being inserted? it's neither null nor empty and there is nothing in there, so I'm completely baffled. If I enter something and wipe it out, it'll be fine.
The IsEmpty() Function is generally only of use to check to see if a variable of type variant has not been initialised.
A database field can be said to be empty which is not the same as if it was Null.
For example if you have a field called Gender which was not a required field on a new record the value could be Null, then if a user typed in Female obviously it would a contain value. If they were then to delete the word Female then the field would now be empty (Not Null).
The most useful function to use when dealing with Nulls in Microsoft Access is the following:
Nz()
This function has two arguments, the first one being the variable you wish to check and the second one being the value you wish to return if the variable is Null. For example the following will return an empty string:
Dim variantName As Variant
variantName = Null
Debug.Print Nz(variantName,"")
Also please note if you try to join a variable that contains Null with a String using the plus character (+) then this will result in Null which is probably where you're having problems.
A try typing the following into the immediate window results are also shown here:
? len(null)
Null
? len(null + "abc")
Null
? len(null & "abc")
3
could be a \r or \n or any other non printable character,
you may want to select such a row and cast it as varbinary to see the content

SSRS and null datetime

I always thought that when a stored procedure brought back a null datetime that an SSRS report would show mindate in that cell. The thing is, in my experience this is not always true. I can't figure out why. Sometimes a report will show blank and sometimes mindate for a null datetime. Why is that?
Is there rules or documentation (that makes sense) that explains how this works? It's hard to be consistent when the tools you are using are not consistent. I can make two reports that are set up exactly the same way. One will show mindate and one will show blank for null datetimes. I don't get it.
EDIT:
First of all, yes the mindate thing has happened to many.
https://www.google.com/search?num=50&q=ssrs+null+date+show+blank&oq=ssrs+null+date+show+blank&gs_l=serp.3...8759.9774.0.9941.10.10.0.0.0.0.152.888.8j2.10.0....0...1c.1.25.serp..8.2.166.kl2WBVx4Ijw
Almost every result has someone talking about the mindate when they want a blank. Many of the results are from Stack Overflow so before you start telling me it never happens, realize you are flat wrong. You may have never seen it. I have never seen a severed finger in my food in all my years of eating and thousands of meals. Doesn't mean it hasn't happened to someone.....
Example of one that is showing min date:
In the report the expression for the text box is:
=Fields!SecondaryInjuryRecordDate.Value
The number formatting was set to Date->01/31/2000 in the placeholder properties window.
Pretty straightforward, nothing weird going on there. RIGHT?
In the proc, the code for that column is:
CASE WHEN ISNULL(l.SecondaryInjury, 0) = 0 THEN '' ELSE l.SecondaryInjuryDXDate END AS SecondaryInjuryRecordDate
That resulted in mindate being shown whenever SecondaryInjuryDXDate was null. I had to switch to this:
CASE WHEN ISNULL(l.SecondaryInjury, 0) = 0 THEN '' ELSE ISNULL(l.SecondaryInjuryDXDate, '') END AS SecondaryInjuryRecordDate
...to get blanks when the date was null.
SecondaryInjuryDXDate is a DATETIME and
SecondaryInjury is a bit.
Within SSRS, by default a NULL DateTime value will be represented as an empty string instead.
If data formatting is applied to the value, a MIN DateTime value will be used in place of the null value e.g.: converting the DateTime to a ShortDate as described:
The number formatting was set to Date->01/31/2000 in the placeholder properties window. Pretty straightforward, nothing weird going on there. RIGHT?
To avoid this, the column value must be wrapped in an expression to conditionally apply the required formatting:
=IIf(IsNothing(Fields!DateTimeField.Value), "", FormatDateTime(Fields!DateTimeField.Value, DateFormat.ShortDate))
Use something like this in textbox expression:
=IIf(IsNothing(Fields!DateTime.Value), "", Fields!DateTime.Value)
It looks like there is no documentation to be found about this. The next best thing is to have this Q&A document things based on our collective experience.
Supposing the question: "What does SSRS do when displaying a DATETIME with a NULL value?"...
...the answer is it will display an empty string instead. There is no reproducible scenario where a NULL value would be displayed as anything else, unless you do some work to that end yourself, for example:
If the query COALESCEs the NULL to something else, e.g. the string "NULL" or a MIN DATETIME;
If you have an expression for the textbox value, e.g. IIF(Fields!MyDateTime.Value Is Nothing, "01-01-1900", Fields!MyDateTime.Value)
Every field returned in a SQL query gets a datatype assigned. Generally, you want to keep dates returned as dates from SQL, not as strings. (Don't format the date to a string in SQL. Do that as close to the presentation layer as possible.)
So instead of this in your query:
CASE WHEN ISNULL(l.SecondaryInjury, 0) = 0 THEN '' ELSE l.SecondaryInjuryDXDate END AS SecondaryInjuryRecordDate
I would try to use:
CASE WHEN ISNULL(l.SecondaryInjury, 0) = 0 THEN CAST( NULL AS DateTime ) ELSE l.SecondaryInjuryDXDate END AS SecondaryInjuryRecordDate
See SQL cast datetime for an explanation of why you are getting 0 cast to a date.
I did find when I format an entire column such as FormatDateTime(field, DateFormat.ShortDate) - SSRS will format that blank field to 01/01/0001. Just an FYI.

Parameter is missing a value ssrs 2008

I have a parameter of integer datatype which is hidden. When i run the report, report gives me an error
Parameter X is missing a value
However if i make the parameter visible it works. I tried providing default value of 0 but that does not suffice my requirement as i have sub-report(Drill-dowm) depended on this parameter. Please help. Thanks!
Make sure that you have not specified Available Values for the parameter. Available Values should be "None" for internal and hidden parameters.
First of all,
Check that parameter's - Available Values by going to report parameters properties.
It must not be specified any values. So we should set it as None
Second work around is,
Just add a blank space at Specify values - in Default values inside report parameters properties.
This will surely work. Hope it will save your time.
I had to do an "if exists" statement for this to go away. It worked for me because it makes it always return a value even if that value is not need by my query.
if exists (my select query)
my select query
else
select '2'
// '2' would never be used, but it made ssrs stop giving me
// the stupid error and execute the rest of the query
If you specify available values from query, then default values must be in list of available values. Default value in (Available) = true.
The problem occurs also, if you have a parameter that depends of another one without "default value" inside the Dataset Query and does not admit null value.
For example:
Parameter 1 have a default value: NameEmployee from the dataset "EmployeeSearch"
But the dataset "EmployeeSearch" have a filter or a parameter inside the query named #Month that indicate the number of the month. So if the value of #Month is null, SSRS will say "Parameter is missing a value".
Assuming you had the same issue as I had, trying to run the report on a web page using a ReportViewer component, I managed to fix that issue by adding a null parameter before rendering the report:
C# code:
var parameters = new List<ReportParameter>();
parameters.Add(new ReportParameter("ParameterName", (string)null));
ReportViewer1.ServerReport.SetParameters(parameters);
Hope that will help
Just need to add 1 default value to get around this error (even though that default value will never be used).
-Under "Report Parameter Properties" for that specific parameter, go to the Default Values page.
-Toggle "Specify values"
-Add a value (I added: "just_a_filler_to_get_around_hidden_value_error" so when I look back at it later I remember why I did such a thing)
-click OK
I want to add to dmbreth's CORRECT answer.
I was missing the concept that the value of the parameter still needed to be tied to something. Originally, I was tying the output of a dataset by using the Available values portion of the parameter properties, but according to dmbreth's answer, that could not be the case. Finally I moved my output dependence settings from the Available Values section to the Default Values section and that did the trick.
So, in summary, in the parameter properties dialogue:
General Page - Allow multiple values checked(this option is specific to my application), parameter visibility set to internal
Available Values Page - None
Default Values Page - Get values from query, [appropriate dataset, value here]
Advanced Page - No significance here
Hopefully, that is clear enough to benefit someone else with the same problem...
I had a similar issue where the default value as set by SSRS is (Null), I didn't need the parameter for my report however; I found it useful for testing to filter down the list so I kept it, I guess I could have deleted it in SSRS on the dataset config. but I changed it to =System.DBNull.Value (I guess this could be any expression) instead and that worked for me, so then I can still pass in a value if need be and also set Available values (had to make sure a NULL value was added to my dataset) if I then decide to unhide at a later date.
There is one other potential here. I have had a situation where the report designer works but the server report object does not. The solution is to delete the server object and then re-save it from the designer.