Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Using Visual Studio 2K8 - passing parameters Post Reply Post New Topic
Author Message
BMackKC
Newbie
Newbie


Joined: 02 Jun 2008
Location: United States
Online Status: Offline
Posts: 6
Quote BMackKC Replybullet Topic: Using Visual Studio 2K8 - passing parameters
     Posted: 02 Jun 2008 at 10:29am
Greetings all.
 
I am just now getting back into Crystal Reports development after a little over two years using SQL Server Reporting Services, and have forgotten some stuff, unfortunately.
 
I am editing within Visual Studio 2008. I have created a report with two subreports. Each of the three reports utilizes its own stored procedure to select data. The SPs are quite simple; essentially 
 
 select * from MyTable where MortgageID = @MortgageId.  
 
MyTable is different in each instance, but the variable MortgageID is the same.
 
When I preview the report, it is asking me to enter the variables for all three stored procedures. I tried adding a subreport link to my variable (none were there previously), but preview still asks me for three variables.
 
Any help would be greatly appreciated.
 
Mike
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 02 Jun 2008 at 5:22pm
Can I ask what brought you back to CR from SSRS? Did you bail on SSRS or are on a new project that only uses CR?

Re your question, this is a common problem people have. I put it in the "Best of the Forum" section of my new Encyclopedia book.

You have the right idea about adding a link from the main report to the subreport, but CR has a trick that you need to use to prevent the multiple prompting problem. When creating the link, CR automatically creates an intermediate variable to pass the value to the subreport. This is what is shown by default in the bottom left-hand corner of the dialog box. What you need to do is click the drop-down box and select the actual parameter that the subreport uses. By doing a direct link from the main report to the subreport, the user won't be prompted multiple times.

You can find out more about my books at Amazon.com or reading the Crystal Reports eBooks online.
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
BMackKC
Newbie
Newbie


Joined: 02 Jun 2008
Location: United States
Online Status: Offline
Posts: 6
Quote BMackKC Replybullet Posted: 02 Jun 2008 at 6:40pm

the company for which I'm working now hasn't implemented SSRS.  I like the tight-knit integration between SSRS and VS, especially the fact that I don't have to make sure I install a reports runtime with every app...and make sure that I have the RIGHT runtime, etc. The delta of SSRS is that it makes it pretty much impossible to do a standalone app, or an app that can run disconnected from its database.

I enjoyed CR when I was using it...but most of my CR development was either standalone, or as part of a tightly integrated CRM package (Pivotal eRelationship). I'm pretty new at the integration with VS, and am a little disappointed at the "heavy lifting" that is required.  It also seems to me that the report writer integrated with VS is not as feature-rich as the standalone product. I did just receive CR 2008, and will be installing it after this application is complete.
 
I will take a look at your suggestion...I found a post on CodeProject.com that supposedly has everything I need (http://www.codeproject.com/KB/recipes/CrystalReports_in_VBNET.aspx), but it hasn't worked so far. Could it be that I am using separate stored procedures for each part of the report? I'm in the middle of recreating the report using commands rather than stored procedures.
 
Thanks, and I look forward to buying your book!
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 02 Jun 2008 at 7:16pm
The post you linked to looks pretty good. I would think that it would work for you once you got any bugs worked out. However, This is a lot of work for a simple fix. It uses the runtime object model to do multiple tasks and you just need to link a couple subreports together. Try what I suggested as see how that works. I think it will be a much cleaner solution for you.
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
BMackKC
Newbie
Newbie


Joined: 02 Jun 2008
Location: United States
Online Status: Offline
Posts: 6
Quote BMackKC Replybullet Posted: 02 Jun 2008 at 8:39pm
worked like a charm...And I LOVE 2008 so far. Now to just remember the interface...
 
Can you recommend a code string or module to use to pass my parameter from VB to CR?
 
Thanks again for yourhelp.
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 04 Jun 2008 at 7:52pm
Glad to hear it!

The quick way to update a parameter is to use the following code:
myReport.SetParameterValue("Country", "USA")
myReport.SetParameterValue("Country", "USA", "subreportname")

Note that the first is the name, the second is the value, and the third is the subreport name (leave blank when passing to main report).

I cover this in Chapter 16 of my book. 
You can find out more about my books at Amazon.com or reading the Crystal Reports eBooks online.
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
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