Print Page | Close Window

parameter passing

Printed From: Crystal Reports Book
Category: General Information
Forum Name: Announcements
Forum Discription: Please check this section for the latest announcements from Crystal Reports Forum
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=16630
Printed Date: 17 May 2024 at 9:12pm


Topic: parameter passing
Posted By: rsj12
Subject: parameter passing
Date Posted: 29 May 2012 at 1:17pm
I have a formula in the Main report that builds the SQL where clause (for MS SQL Server) to be passed to the subreport.
 
Query generated by Crystal in the subreport is the following:

SELECT UNIFIER__COSTCOMRPT.PROGRAMNO, UNIFIER__COSTCOMRPT.PROGRAM, UNIFIER__COSTCOMRPT.AMOUNT, UNIFIER__COSTCOMRPT.MYTYPE, UNIFIER__COSTCOMRPT.project_id, UNIFIER__COSTCOMRPT.PROJECTNO, UNIFIER__COSTCOMRPT.PROJECT, UNIFIER__COSTCOMRPT.EFDATE, UNIFIER__COSTCOMRPT.CODE, UNIFIER__COSTCOMRPT.ITEM, UNIFIER__COSTCOMRPT.WO, UNIFIER__COSTCOMRPT.PROJTYPE

FROM unifier.dbo.unifier__costcomrpt UNIFIER__COSTCOMRPT

WHERE UNIFIER__COSTCOMRPT.project_id=1019

AND UNIFIER__COSTCOMRPT.EFDATE<{ts '2012-05-30 00:00:00'}

AND UNIFIER__COSTCOMRPT.WO=

SQL string built in the main report formula and passed as a parameter (called mailto:%7b?Pm-@WO_Selection_Formula - {?Pm-@WO_Selection_Formula }) to the subreport looks like this:
 
HA1191' OR WO = 'HA1194' OR WO = 'HA1273
 
 
The selection formula in the subreport is the following:
 
{UNIFIER__COSTCOMRPT.project_id} = {?Pm-unifier__costcomrpt.project_id} and
{UNIFIER__COSTCOMRPT.EFDATE} <= mailto:%7b?Pm-@DateParam - {?Pm-@DateParam } and
{UNIFIER__COSTCOMRPT.WO} = mailto:%7b?Pm-@WO_Selection_Formula - {?Pm-@WO_Selection_Formula }
 
 
when the complete SQL is generated in the subreport there are extra single quotes added into the Where clause as shown below that cause the subreport to not select any data:
 

AND UNIFIER__COSTCOMRPT.WO=' HA1191'' OR WO = ''HA1194'' OR WO = ''HA1273 '

I have tried manipulating the quotes in the parameter being passed but can't seem to get the quotes to generate properly.

what causes these extra quotes to be generated?
Is there any solution for this?
Thanks!


-------------
rsj



Replies:
Posted By: sgtjim
Date Posted: 01 Jun 2012 at 5:17am
Make sure that the what value type the parameters are set to. When setting up parameters from the 'Modify Command' object window you set the value type from the 'Value Type' drop down box.

If this type is set to string then it will throw quotes in. I know the number type does not. I have not work much with the other types.

The SQL generated by Crystal can sometimes produce results that are less than desirable. At least for me. If this issue present I would try and codes the report directly in SQL and then make the report a command objects report. I have had much better time with these type of report.



Print Page | Close Window