Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: using a dynamic parameter in SQL command Post Reply Post New Topic
Author Message
ehchad
Newbie
Newbie


Joined: 15 May 2012
Location: United States
Online Status: Offline
Posts: 2
Quote ehchad Replybullet Topic: using a dynamic parameter in SQL command
     Posted: 16 May 2012 at 7:00am

Confused I hope I am explaining this adequately!! 

The report I am writing requires me to allow users to fill two parameters based on a field in a table (dynamic parameter list of the field) and the parameters are used to control data selected (current period date and previous period date).  Doing this results improper data being returned. I am not getting records that do not have a match in either one of the periods. So I decided to use the Sql command and write my own code. This is working quite well. However, I hard-coded the dates during my initial testing. How do I go about getting the parameters the user selects from the dynamic list incorporated into my SQL Command?
 
Thanks in advance for the advice.
 
 
IP IP Logged
rkrowland
Senior Member
Senior Member
Avatar

Joined: 20 Dec 2011
Location: England
Online Status: Offline
Posts: 259
Quote rkrowland Replybullet Posted: 17 May 2012 at 12:10am
The only way would be to use a subreport.
 
In your main report you need to create the dynamic parameters based on the table mentioned. For the example we'll name them {?mdate1} and {?mdate2}.
 
Then in your subreport enter your SQL command, you'll need to create 2 parameters in your subreport too. We'll call these {?srdate1} and {?srdate2}. Where you've hardcoded dates in the SQL query replace with the corresponding parameter names, ie replace '2012-05-12' with {?srdate1}.
 
Now you've done that, you'll need to link your subreport to the main report so the dynamic parameters can be taken into consideration. Open the edit links dialog of your subreport and link {?srdate1} to {?mdate1} and {?srdate2} to {?mdate2}.
 
That should give you what you need, if you get stuck give me a shout.
 
Regards,
Ryan. 
IP IP Logged
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