Is it possible to have more than one condition to suppress a row in crystal reports? - crystal-reports

I'm trying to put together a report to track our record reviews. In order to not have duplicates I have a condition to suppress a row if it's a duplicate
{review.clientNo} = Previous({review.clientNo})
and it works fine.
For who knows reasons one of our employees who does not do record reviews has access to two fields that relate to the tables of the record reviews and they keep checking off these fields even though they don't need to. So even if that particular record was not reviewed it still shows up on the report because two fields within it have entries. Until we can undo that we still want to run the reports. So I want to have two conditions to suppress either the one i have typed or the one in which only those fields are present and all others a null
This is what I have so far but crystal reports isn't liking it.
{review.clientNo} = Previous({review.clientNo})
or isnull( {review.initialDate} + {review.followUp} +
{review.code47A} +{review.clientSales} + {review.totalSales} +
{review.salesQuantity} +{review.clientSatisfaction} + {review.clientAddress}
+ {review.clientEmail} +{review.clientNumber} + {review.orderNumber} +
{review.orderTrack} + {review.orderFill} + {review.orderAmount} +
{review.orderSize} +{review.deliveryMethod} + {review.salesDate} + {review.orderDate})

Create a formula called suppression
if
{review.clientNo} = Previous({review.clientNo}
or
(
isnull({review.initialDate})
AND isnull({review.followUp})
AND isnull({review.code47A})
AND isnull({review.clientSales})
AND isnull({review.totalSales})
AND isnull({review.salesQuantity})
AND isnull({review.clientSatisfaction})
AND isnull({review.clientAddress})
AND isnull({review.clientEmail})
AND isnull({review.clientNumber})
AND isnull({review.orderNumber})
AND isnull({review.orderTrack})
AND isnull({review.orderFill})
AND isnull({review.orderAmount})
AND isnull({review.orderSize})
AND isnull({review.deliveryMethod})
AND isnull({review.salesDate})
AND isnull({review.orderDate})
)
then 1 else 0
in the suppression for your header and footer try this
sum({#suppression},{fieldgroupedon}) =0
You could also, by the way, now change your detail record suppression to just
{#suppression} = 1
I hope I got all that right!

Related

Crystal Reports Formula: Help forming IIF Statement

I am working with Crystal Reports 11.5.10.1263 [CR Developer Type: Full].
I am familiar with Programming and SQL syntax in general and have worked with expressions in SSRS & MS Access but never in Crystal Reports.
Problem:
I modified the SQL in the Crystal report and it has had the desired effect - except in the last part of the report output - where the changes I made to the SQL do not have the desired effect.
The 'desired effect' is that when a field named 'FundNumber' has the values '2595', '2597' Then the field named 'Organization' should be assigned the value '41600'.
The Detail Record in the Report has the following three rows as part of its 'Formula':
+ IIf({Data.Payments} > 0, "+01W ", "-01W ")
+ Left({Data.FundNumber}+ SPACE(6),6)
+ Left({Data.Organization}+ SPACE(6),6)
I want to change the Data.Organization row to an IIF Statement that says [pseucode]:
IIf Data.FundNumber IN ["2595", "2597"] Then "41600" Else Data.Organization
I believe the Left() function is saying 'return the left 6 characters of [Data.Organization + 6 Spaces] ?? and that it has to do with the way the data is presented in the output.
I would appreciate help with creating the IIF statement for this.
I included the 'IIf({Data.Payments} ...' row in case that helps - as my google searches have turned up examples that use IF instead of IIF.
Thanks!
The syntax most of the time is the same as VB. Try
IIF({Data.FundNumber} = "2595" or {Data.FundNumber} = "2597", "41600", {Data.Organization})

Error in Opening Report from Form

I have a Form which will help me to filter out the records I want for my Report. The button will open the Report On Click.
This is the code in the button:
Private Sub Open_OEE_Click()
DoCmd.OpenReport "OEE_Report", acViewReport, , , acWindowNormal
End Sub
I keep getting the error:
I also have placed the query in my report under the Record Source as:
SELECT * FROM 3_OEE WHERE ((([3_OEE].RecordID)=Forms![3_OEE_Report]!cboRecordID) And (([3_OEE].Date_Recorded)=DateValue(Forms![3_OEE_Report]!Date_Recorded)) And (([3_OEE].MC_No)=Forms![3_OEE_Report]!cboMCNo) And (([3_OEE].Product)=Forms![3_OEE_Report]!cboProduct));
I want to search based on one criteria (text box or combo box) and not all four at once.
Am I missing out something?
MS-Access does tend to go a bit overboard with the brackets. Make the report's Record Source a bit easier to read by trimming out the unnecessary ones. You also need to get your date criterion in the right format - Access always uses US formatting in SQL queries and needs # signs around the date:
SELECT * FROM 3_OEE
WHERE [3_OEE].RecordID = Forms![3_OEE_Report]!cboRecordID
And [3_OEE].Date_Recorded = Format(Forms![3_OEE_Report]!Date_Recorded, "\#mm/dd/yyyy\#")
And [3_OEE].MC_No = Forms![3_OEE_Report]!cboMCNo
And [3_OEE].Product = Forms![3_OEE_Report]!cboProduct;
I would also suggest creating a named query for this and setting the report's Record Source to the named query. You can then test the query in isolation without having to run the report (but make sure the Form is open and the relevant controls are populated).
I asked for help from another source.
Answer to Question

Merge data from many sheets on to one

In excel, I have several sheets (around 50), each with an identical header in columns A, B and C, and then up to 199 rows of data (row 1 = header, rows 2-200 = data). The naming routine is as Wk 1 Mon, Wk 2 Tue, etc, all the way up to Wk 10 Fri
What I would like to do is display all of the data from these tabs in one list, on one sheet. I could potentially do this by referencing each cell from each sheet, one under the other, but the problem is that not all sheets actually have data right the way down to row 200 (some have just the header), and I wish to skip empty rows.
I have absolutely no clue how to approach this in Excel. My understanding of VLOOKUP and the like is rudimentary at best; I'm not sure if I could even achieve what is required by using that family of functions.
I've also looked in to the Consolidation feature of Excel, but I don't think that is what I need in this scenario.
Could someone please suggest how I may achieve my goals. I would prefer to do this via worksheet only functions, but I'd be open to VBA if there was an easy enough solution.
Try this bit of VBA. It basically scrolls through each worksheet, finds the last row and pastes it on the bottom of the first sheets data. It's a bit crude in methodology but it does work!
Dim ws As Worksheet
For Each ws In Worksheets
i = i + 1
If i = 1 Then
FirstSheet = ws.Name
ElseIf i > 1 Then
ws.Activate
LastCell = Cells(65536, 1).End(xlUp).Row
Range("A1:C" & LastCell).Select
Selection.Copy
Worksheets(FirstSheet).Activate
Cells(Cells(65536, 1).End(xlUp).Row + 1, 1).Select
ActiveCell.PasteSpecial xlPasteValuesAndNumberFormats
End If
Next ws

Crystal Reports incorrectly printing duplicate data

I am modifying a subreport that prints optional report card comments. The data that is supplied (via a stored procedure) is in this format (trimmed for brevity):
StudentID / Grade / CourseNum / ReportCode / CName / Comment
9999991 / KG / EA0_AM1 / M1 / T1Comment / Pam is good!
9999991 / KG / KP0_PM1 / M1 / T1Comment / Pam is okay!
9999992 / 3 / EA3_AM1 / M1 / T1Comment / Joe is good!
9999993 / 5 / EA5_AM1 / M1 / T1Comment / <null>
If a student is not in kindergarten, the only comment I want to print is the one where CourseNum = "EA?_AM1". If they're in Kindergarten, however, the comments should pull from "EA0_AM1", "EA0_PM1", "KP0_AM1", and "KP0_PM1", and those comments should be concatenated. The original report would only print the comment from either "EA0_AM1" or "EA0_PM1", but not both (it didn't know about the other two kindergarten classes, and it used a running total to find the maximum value for Comment), but among the four potential classes there are two potential teachers, and this year they both want their comments to appear on the report card. I don't think it matters, but here's the record selection formula:
(Select {?Marking Period}
Case '1' : {ReportCode} = 'M1'
Case '2' : {ReportCode} in ['M1', 'M2']
Case '3' : {ReportCode} in ['M1', 'M2', 'M3']) and
(Select {Grade}
Case 'KG': {CourseNum} in ["EA0_AM1", "EA0_PM1", "KP0_AM1", "KP0_PM1"]
Default : {CourseNum} like "EA?_AM1")
({?MarkingPeriod} refers to the trimester we're interested in.)
The problem I'm encountering springs from the fact that we want to print T1, T2 and T3 comments separately. I found the start of my solution in an answer given by Abhilash Kumar in a thread here: http://scn.sap.com/thread/3195910. Based on his answer to someone else's question I created a formula GetAllCommentsT1:
WhilePrintingRecords;
stringvar array arrT1;
numbervar iT1;
if not(({Comment} in arrT1) and ({CName} like "T1*")) then
(
iT1 := iT1 + 1;
redim preserve arrT1[iT1];
arrT1[iT1] := {Comment};
);
arrT1[iT1]
GetAllCommentsT2 and GetAllCommentsT3 are identical except that all instances of "T1" are replaced with "T2" and "T3" respectively. I placed these three formulas in the Details section (this section is suppressed: only Group Footer 2a through 2d are enabled).
To display the results, I created three formulas (DisplayT1Comments, DisplayT2Comments, and DisplayT3Comments). All are similar to this:
WhilePrintingRecords;
stringvar array arrT1;
join (arrT1, CHR(13) + CHR(13))
with "T1" replaced with "T2" or "T3" as appropriate. DisplayT1Comments is placed in Group Footer 2b, DisplayT2Comments is placed in Group Footer 2c, and DisplayT3Comments is placed in Group Footer 2d.
Using the data mentioned at the beginning of this question, for StudentID: 999991 DisplayT1Comments is "Pam is good!\n\nPam is okay!", and that's exactly what prints in Group Footer 2b. Since no T2 or T3 comments have been entered yet (verified directly in the database), I would expect both DisplayT2Comments and DisplayT3Comments to be null. However, when I run the subreport the contents all three footers are displaying "Pam is good!\n\nPam is okay!"
Any ideas what I've done wrong? Or maybe suggestions for a better solution (i.e.: one that works!) to my problem? Thanks!
The problem was a stupid logic error on my part: the line that read
if not(({Comment} in arrT1) and ({CName} like "T1*")) then
should have had the not moved inside the first parenthesis, so it negated ({Comment} in arrT1), and not the whole thing. That's what I get for blindly rushing in to modify existing code rather than sit down to think for a moment. Thanks to those who asked for clarification.

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".