Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Setting parameters in Crystal Reports XI Release 2 Post Reply Post New Topic
Author Message
Dawn
Newbie
Newbie
Avatar

Joined: 19 Mar 2007
Location: United States
Online Status: Offline
Posts: 4
Quote Dawn Replybullet Topic: Setting parameters in Crystal Reports XI Release 2
    Posted: 19 Mar 2007 at 6:12pm

I know this isn't .net, but you guys here seem very knowledgeable and I am DESPIRATE for an answer. 

We have many reports we run through a VB6 program, setting various parameters before printing or displaying.  For most reports, the parameters are not changing, they are staying with older values (last used in testing/dev of actual report).

I'm 99.9% sure I've got the code right.  Just that some reports work and other do not, with the same code.  All reports use stored procedures as ther source/tables.  The only difference we can see is that reports that do not work have a date parameter and the ones that do work do not have a date parameter.  For the reports that do not work, no parameters are getting set.

Code sample (is very abbreviated, but wanted to show the basic of the code):
    For i = 1 To g_CrystalReport.ParameterFields.Count
        Set CRParameter = g_CrystalReport.ParameterFields(i)
        With CRParameter        
            Select Case .Name
                Case "{?@Portfolio}"
                    Call .SetCurrentValue(strPortfolio, crStringField)
            End Select
        End With
    Next i

I tried the new functionality using method AddCurrentValue, but that works worse, if that makes sense!  I don't want to get too long in this email.

I'm pushed for time and need this done tonight!

Thanks to anyone who can help!!

IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 19 Mar 2007 at 6:27pm
I'm not sure what is going wrong, but I have a couple comments. First off, are the parameters being passed to the stored procedure or is the filtering done locally withing the report? If on the stored procedure I would use the SQL Server trace tool to see what is actually getting passed from CR to the database and debug from there. Secondly, if you can't find a solution, as a last resort I would make the parameter a string and then have a formula that converts the string to a date. This is obviously a hack, but it might get around the problem of the parameter not getting passed from your application to the report.

Oh yeah - is it not getting passed to the report or is the report not passing it correctly to the database? Could be how the date is formatted in your application and its datatype and whether that is compatible with the database. Again, I don't have the answer for you; just some things I would look at in hopes of finding the right answer (if you find out please let us know so that we can all learn from it).
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
Dawn
Newbie
Newbie
Avatar

Joined: 19 Mar 2007
Location: United States
Online Status: Offline
Posts: 4
Quote Dawn Replybullet Posted: 19 Mar 2007 at 6:35pm

Brian,

I'll try anything at this point!

The parameters are Crystal parameters and then passed to the stored procedure.

I've already traced and Crystal is sending the old (stored from development of the report) to the server.  In fact, I have steped through the code...checking the parameters current before setting (old value) and then after setting the current value (still old value). 

The dates are all datetime in Crystal.  I am passing a VB date field. 

It's 'funny' because the date is the last parameter in the list, but no field is getting set.  I am going to try making the date a string...  I'll post again when I'm done.

Any chance that Release 2 is just too immature...I'm finding so many other problems as well...
 
Thanks again!
 
Dawn
IP IP Logged
Dawn
Newbie
Newbie
Avatar

Joined: 19 Mar 2007
Location: United States
Online Status: Offline
Posts: 4
Quote Dawn Replybullet Posted: 19 Mar 2007 at 7:39pm

I decided instead of going through the pain of changing the date field to string, I'd look around at report options a bit more. 

Bottom line of my descovery is that crReport.DiscardSavedData clears out any data inadvertently saved with the report, and clears the parameters.  Once the parameters are cleared, they are ready to accept new values!  (The ParameterFieldDefinition method ClearCurrentValueAndRange does not work!)

Thanks again Brian and hopefully, my pain will be someone else's gain!
 
Dawn
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 19 Mar 2007 at 8:29pm
I'm glad you found the problem! That is strange that the other parameters were accepted but not the dates though. They should either all be accepted or none.

Thanks for letting us know what happened. I'll make a note to remember about the DiscardSaveData method to tell others. 
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
Dawn
Newbie
Newbie
Avatar

Joined: 19 Mar 2007
Location: United States
Online Status: Offline
Posts: 4
Quote Dawn Replybullet Posted: 20 Mar 2007 at 7:37am
Clarification:
 It wouldn't accept ANY parameters...it seems that the reports with the date parameters were the ones with the problem, but who knows, could be just how the reports were saved.  I did not develop the reports!
 
Good luck!
 
Dawn
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 20 Mar 2007 at 11:40am
Ok. Well that's good to know. I'll make sure I clarify the problem in my next book. Thanks.
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
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.039 seconds.