Print Page | Close Window

Print parameters in a no data report...

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=1844
Printed Date: 28 Apr 2024 at 11:40am


Topic: Print parameters in a no data report...
Posted By: .netter
Subject: Print parameters in a no data report...
Date Posted: 06 Dec 2007 at 4:17pm
Using CR in .NET 2003...
 
I have a stored procedure that performs 2 different selects. 
The first selects records to print in CR.  The second selects report parms
entered into a asp.net form.
 
The trouble I'm having is that, in the page header of the CR, I want to print the parameters the user input from the asp.net form... but if it is a report with no data from the first select, the report parameters from the second select don't print either.
 
What I need to have happen is that the report parameters from the 2nd select print, regardless of whether there is any data for the report.
 
Here is what the SP looks like:
 
---------------------------------------------------
CREATE PROCEDURE spITIlocStockSummRpt
@sprojNum varchar(5),
@sprojName varchar(150),
@slocNum bigint,
@slocName varchar(150)
AS
DECLARE @parmItems TABLE
(
   projCode varchar(25),
   projName varchar(150),
   locNum bigint,
   locName varchar(150)
)
INSERT INTO @parmItems (projCode, projName, locNum, locName) VALUES (@sprojNum, @sprojName, @slocNum, @slocName)
 
SELECT pli.ITIprodCode, pli.qtyIN, p.prodName, p.vendprodCode, p.prodUOM, v.vndName, ptc.productTransactionCnt
FROM ProjectLocationInventory pli LEFT OUTER JOIN ITIProductTransCntByProject ptc ON ptc.projCode = pli.projCode AND ptc.ITIprodCode = pli.ITIprodCode AND ptc.projCode = @sprojNum, ITIProducts p, ITIvendors v
WHERE pli.projCode = @sprojNum
AND pli.plID = @slocNum
AND p.ITIprodCode = pli.ITIprodCode
AND v.vndCode = p.vendCode
ORDER BY p.prodName
;
SELECT projCode, projName, locNum, locName
FROM @parmItems
GO
---------------------------------------------------
 
So, the values from the select against the @parmItems need to print in the report, regardless of whether there is data from the other select.
 
Both tables, with fields, show up in the CR database viewer.
 
Help, this is driving me nuts!
 



Replies:
Posted By: Lugh
Date Posted: 07 Dec 2007 at 7:47am
Question #1:  Are these parameters being passed to parameter fields in Crystal?  If so, you know you can just print parameter fields right on the report, right?  I'm going to assume that, for the sake of this reply, this is not the case.

Crystal is going to have real problems trying to process disconnected recordsets. 

Normally, in a case like this, I would strongly advocate the use of a subreport.  But, I'm at something of a loss, off-hand, as to how to do that with this structure.

As a question, why are you putting your parameters into a table?  There's only one of each parameter, right?

My solution would be to use a UNION query to create a dummy record with the parameter values in it.  So, after your first SELECT statement, put:

UNION ALL

SELECT projCode AS ITIprodCode, 0 AS qtyIN, projName AS prodName, slocNum AS vendprodCode, 'DUMMY' AS prodUOM, slocName AS vndName, 0 AS productTransactionCnt
FROM @parmItems



In your report, make sure to suppress the record with 'DUMMY' in prodUOM.  Create SQL Expression fields to pull the values where prodUOM = 'DUMMY', and put those fields in your report header.





Print Page | Close Window