Solved

Crystal Reports storing input parameters/Calling from VB6

Posted on 2007-03-22
5
229 Views
Last Modified: 2013-12-25
I have a Crystal Reports 8 report whose SQL command is:

{call db.dbo.GetHistoricalApprovalRecords;1(?,?)}

GetHistoricalApprovalRecords is a stored procedure that takes two DateTime parameters, the period's start date and the period's end date.

The report itself works great.  If I hit refresh, it gives me the option to prompt for new values or use the current values.  That's not a problem.

However, when I call this report from Visual Basic 6, it uses the current values in the two DateTime input parameters (specifically, it uses the last two values I explicitly put in and saved the report).  I imagine Crystal stores those values in the report itself.    

My question is if it is possible to stop this behavior.  I would like to be prompted every time the report is opened, refreshed, etd.  I do not want to store any values in the report itself.

Notes:
The two input parameters are from the stored procedure that I added to the report.  

The code from VB6 is:
Set app1 = CreateObject("Crystal.CRPE.Application")
Set rpt2 = app1.OpenReport("\\reportShares\ApprovalRecords.rpt")
rpt2.Database.Tables(1).SetLogOnInfo sqlserver, db, uid, pwd

rpt2.Preview

If possible, I do not want to pass the input values from VB6 to the report.  I would like to open the report from VB6 and ahve it automatically prompt me for the values.  

Thanks in advance!  
0
Comment
Question by:LA_Code_Poet
  • 3
5 Comments
 
LVL 100

Accepted Solution

by:
mlmcc earned 500 total points
ID: 18774475
Make sure the report isn't saved with data
Open the report in Crysta;
Click FILE
Unckeck SAVE DATA WITH REPORT

mlmcc
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 18774491
Another option
Open the report in Crystal
CLick FILE --> OPTIONS
Click the DATABASE tab
Click REPROMPT WHEN OPENING

mlmcc
0
 
LVL 11

Expert Comment

by:TreyH
ID: 18787511
See if the report object has a 'DiscardSavedData'

Set app1 = CreateObject("Crystal.CRPE.Application")
Set rpt2 = app1.OpenReport("\\reportShares\ApprovalRecords.rpt")

rpt2.DiscardSavedData '<--- Try adding this line.

rpt2.Database.Tables(1).SetLogOnInfo sqlserver, db, uid, pwd
0
 
LVL 16

Expert Comment

by:JohnBPrice
ID: 18792681
You can also clear the previous parameter values, which should cause Crystal to prompt you.  Do:

rpt2.ParameterFields.Item(1).ClearCurrentValueAndRange

repeat as need for multiple parameters.

0
 
LVL 100

Expert Comment

by:mlmcc
ID: 18838128
Glad i could help

mlmc
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now