Announcements
 Crystal Reports Forum : General Information : Announcements
Message Icon Topic: parameter passing Post Reply Post New Topic
Author Message
rsj12
Newbie
Newbie
Avatar

Joined: 13 Mar 2012
Location: United States
Online Status: Offline
Posts: 8
Quote rsj12 Replybullet Topic: parameter passing
    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 {?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} <= {?Pm-@DateParam} and
{UNIFIER__COSTCOMRPT.WO} = {?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
IP IP Logged
sgtjim
Newbie
Newbie
Avatar

Joined: 23 Aug 2011
Online Status: Offline
Posts: 32
Quote sgtjim Replybullet 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.
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.031 seconds.