I need the details section to suppress if a custom date field is blank in Crystal Reports - crystal-reports

I have the following suppression formula in the details section:
{JCJM.udRough} <= #1/1/2013 12:00#
AND
{JCJM.udTrim} <= #1/1/2013 12:00#
and it works. However, I also need it to suppress if the udRough or udTrim field is blank. When I try to add
OR {JCJM.udRough}=""
it says that a date-time is expected where the blank quotes are.
Can someone please help?

As a general rule in CR, if a field can be null then you should explicitly check for that case first in a formula, otherwise it will not evaluate properly. Otherwise, CR will treat it like an unhandled exception.
So in your case, CR is short-circuit evaluating the expression {JCJM.udRough}<=#1/1/2013 12:00# as the very first thing, sees that the field is null, and stops evaluating the rest of the formula since it has encountered an exception.
What you need is:
(isnull({JCJM.udRough}) or {JCJM.udRough} <= #1/1/2013 12:00#)
and (isnull({JCJM.udTrim}) or {JCJM.udTrim} <= #1/1/2013 12:00#)

Try
if ISNULL({JCJM.udRough})
Then true
else false
This is from my understanding from your question if you are searching for something different let me know will try to answer it.

Related

Smartsheet function is UNPARSEABLE

On the Sheet Summary I'm trying to write a function that will track Past Due tasks below is the format :
=COUNTIF([Is Past Due?]:[Is Past Due?], "Yes")
The formula doesn't work as it says "UNPARSEABLE". Below is the Past Due column name
The UNPARSEABLE error in Smartsheet happens when, the formula has a problem which prevents it from being parsed and interpreted.
Example:
-misspelling
-incomplete operators
-using the wrong case for a column name
-using single quotes instead of double quotes
Maybe, you have to review the syntax of the function COUNTIF, and make sure to use acceptable operators, follow this link for more information about the function
---Syntax---
COUNTIF( range,criterion )
range
— The group of cells to count.
criterion
— The value that determines which cells in the range will be counted.
I hope this information can be useful for you.

Unable to deciper formula field syntax

I'm trying to decipher a Crystal Reports formula field, but I'm not sure what this syntax is saying. I understand what the ISNULL() is for, but does the >"." mean?
if isnull({r.userid}) or not ({r.userid}>".") then {r.empID} else {r.userid}}
What is the or not ({r.userid}>".") statement saying? I don't follow the logic in that.
That's an interesting way to do this but it is basically saying
if userid is null or if the asci value of the first character of userid is NOT greater than 46. This will return The username if it is not null or starts with anything other than special characters.

Invalid Name Error - Crystal Reports in VB6

I'm trying to set the title of a crystal report in VB6, but I keep being shown an error.
The parameter field that I want to set the text of is called txtTitle.
However, when running this code, it gives an error saying
Invalid Name
If opt_sales_ledger.Value = True Then
crxReport.ParameterFields.GetItemByName("txtTitle").AddCurrentValue ("List of Sales Ledger Accounts")
ElseIf opt_purchase_ledger.Value = True Then
crxReport.ParameterFields.GetItemByName("txtTitle").AddCurrentValue ("List of Purchase Ledger Accounts")
End If
What's causing the error?
Crystal is looking for a "parameter" type field called "txtTitle" and it cannot locate it. I usually use formulas for this purpose, in other words "txtTitle" would be a formula in the report and defined and/or initialized as a stringVar
Try to use this way:
crxReport.ParameterFields(1).AddCurrentValue ("your_first_parameter_value")
crxReport.ParameterFields(2).AddCurrentValue ("your_second_parameter_value")
Good luck!

Else part never getting executed in crystal report formula field

I have a simple formula in crystal syntax which looks something like this :
if isdate(totext({Absence Details.Return to Work Interview Date})) = true
and {Absence Details.Return to Work Interview required} = true then
1
else
0;
This is the actual code of the formula
but the else part is never getting executed, when the condition is not true report just shows blank. I am not sure what I am doing wrong here.
Thanks in Advance.
- Amit
Maybe you have some null value in your fields - in such case crystal just returns null. You then need either "convert null values to default" setting for report or explicit testing against nulls.
Edit: NM, code was posted to the comments. Doesn't look like this is the issue.
My guess, assuming you've debugged correctly is that you've got a semicolon somewhere you shouldn't.
if {something} = x then
do something;
else
do something different;
instead of
if {something} = x then
do something
else
do something different;
This would cause the behaviour, assuming it doesn't choke on the orphaned else clause. But as the comments say, short of posting real code, we can only guess at what's going on. It could be as simple as your evaluation is always true.
Change the 0 to a 7 and see if it actually prints 7. Some report generation tools (and I have little experience with Crystal but quite a bit with others) will leave fields blank if they're zero - this often helps in reading the report by reducing unnecessary clutter.
If the 7's print out, then that's what the problem is, and it's a matter of figuring out how to get Crystal to output an actual 0.
That may be a matter of configuring the output field or even stting it to a textual "0" instead of numeric 0.
Of course, if that doesn't print out 7's, then feel free to let me know.

Crystal reports 11 : blank field bombs the report

I'm creating a invoice crystal report for sage mas 500 AR module. In it, I'm attempting to add the tarinvoice.balance field with the following formula:
if {tarPrintInvcHdrWrk.Posted} = 1 then
ToText({tarInvoice.Balance})
I'm assuming that when the {tarPrintInvcHdrWrk.Posted} = 1 conditional statement holds FALSE, it doesn't attempt to pull the invoice field because when I remove the formula from the report, the form displays correctly without it.
When the conditional statement renders true in the report, the balance fields behaves correctly. However, with the formula renders FALSE in the CR form, the entire crystal report bombs and displays blank. Any ideas why or what I'm doing wrong?
Just tried setting everything to zero and the report still bombs. I'm starting to think its more of a query error in the report. I wish there was a way to exclude the field in the query when posted = 0.
With tarinvoice.balance removed when the posted = 0, the report works fine.
With tarinvoice.balance included and posted = 1, report works fine.
With tarinvoice.balance included and posted =0, report bombs.
I believe the conditional statement fails immediately if you encounter a NULL, so your formula needs to test IsNull({tarPrintInvcHdrWrk.Posted}) before it tests equality with "1".
You can change the way Crystal handles a null value for a value in a formula. At the top of the Formula Workshop there is a drop down box that usually says "Exceptions For Nulls".
Change this to the other option "Default Values For Nulls" and your formula should no longer bomb out. You used to be able to specify the what the default values applied were, but more recent versions of Crystal have these hard coded.
Search the help for "Null Treatment" for a table showing them.
I modified the formula to this:
if isnull({tarPrintInvcHdrWrk.Posted}) = FALSE then
if {tarPrintInvcHdrWrk.Posted} = 1 then
if isnull({tarInvoice.Balance}) = FALSE then
ToText({tarInvoice.Balance})
else
"0.00"
else
"0.0"
else
"0"
The crystal report still bombs.. Nevertheless, it does show "0" in the appropriate space.
I saw a suggestion on Exp.Exch to try putting the field into a variable before converting it to text.
e.g.
NumberVar InvoiceBalance;
If isnull({tarInvoice.Balance}) then
InvoiceBalance := 0
Else
InvoiceBalance := {tarInvoice.Balance};
If {tarPrintInvcHdrWrk.Posted} = 1 then
ToText(InvoiceBalance);
I also tried to recreate your problem, since I have see similar things before.
No luck though trying with CR 8.5 & XI R2. Perhpas it has to do with linked tables as well, since I only tried on a simple single table.
I have also seen similar behaviour when using a formula within a Running Total - they do not like nulls at all!
If you put {tarInvoice.Balance} directly on report (into details "debug" section - often needed, don't forget supress it in production :)), what values it displays or does report become empty?
Maybe you have Suppress If Blank section on your report. Try to put: Else " "
if isnull({tarPrintInvcHdrWrk.Posted}) or {tarPrintInvcHdrWrk.Posted}=0 then
" "
else
if {tarPrintInvcHdrWrk.Posted} = 1 then
ToText({tarInvoice.Balance})
else
" "
I have trouble with this kind of field when making reports to export to excel. A field with no data in will pull all columns to the right of it over to "fill the gap".