|
-
Nov 27th, 2000, 02:23 AM
#1
Thread Starter
New Member
Pass parameters to Crystal Reports 8 ???
Hi,
I'm using Visual Basic 6.0 and Seagate Crystal Reports 8. I want to view a report called from Visual Basic. The report is made in Crystal Reports and has some parameters. Now, my question is: How can I pass parameters through Visual Basic to call my report.
Second problem: I open my report in the ActiveX viewer an I get the first page from my report. If I try to refresh my parameters, or if I try to go to the second page, I get the error : "Server has not yet been opened".
Please, need urgent help, desperate!!
Thanks very much,
Billy.
[Edited by Billy on 11-27-2000 at 02:46 AM]
-
Nov 27th, 2000, 03:54 AM
#2
Fanatic Member
-
Nov 27th, 2000, 04:29 AM
#3
Hyperactive Member
heres some code that may help...
Dim m_objReport As CRAXDRT.Report
Dim m_objApp As New CRAXDRT.Application
Dim params As CRAXDRT.ParameterFieldDefinitions
Dim param As CRAXDRT.ParameterFieldDefinition
Set m_objReport = m_objApp.OpenReport("REPORTNAME", 1)
m_objReport.EnableParameterPrompting = False
m_objReport.Database.SetDataSource DATASOURCED
m_objReport.Database.Verify
m_objReport.ReadRecords
Set params = m_objReport.ParameterFields
For Each param In params
With param
.ClearCurrentValueAndRange
.AddCurrentValue EACHVALUEHERE
End With
Next
With lgfgReport
.ReportSource = m_objReport
.ViewReport
.Zoom 1
End With
Regards
Chris
-
Nov 27th, 2000, 08:09 AM
#4
Thread Starter
New Member
Thanks. I tried the code, but then I get the error: "Server has not yet been opened". What exactly do you mean with 'DATASOURCED' and what is 'lgfgReport'?
-
Nov 27th, 2000, 08:19 AM
#5
Fanatic Member
-
Nov 27th, 2000, 09:17 AM
#6
Thread Starter
New Member
I am using the 'Crystal Report Viewer Control'. This has no connect property. I'm making a connection as followes:
con = "Provider=OraOLEDB.Oracle.1;Persist Security Info=False;Data Source=orcl"
con.ConnectionTimeout = 300
con.CommandTimeout = 300
con.Mode = adModeRead
con.IsolationLevel = adXactReadCommitted
con.CursorLocation = adUseClient
con.Open con, "userid", "password"
Set crxApp = New CRAXDRT.Application
If I call my report without trying to pass parameters, the CRViewer is showing the report. If I try to pass parameters with the following code, I get the error "Server has not yet been opened".
Set crxReport = crxApp.OpenReport("C:\path\report.rpt")
Set crxParameterFieldDefinitions = crxReport.ParameterFields
Set crxDatabase = crxReport.Database
Set crxDatabaseTables = crxDatabase.Tables
For Each crxDatabaseTable In crxDatabaseTables
Set DatabaseTable = crxDatabaseTable
Exit For
Next crxDatabaseTable
DatabaseTable.SetLogOnInfo "test", "test", "userid", "password"
For Each crxParameterFieldDefinition In crxReport.ParameterFields
Select Case crxParameterFieldDefinition.Name
Case "{?code}"
crxParameterFieldDefinition.ClearCurrentValueAndRange
crxParameterFieldDefinition.AddCurrentValue CStr(code.Text)
End Select
Next
Can somebody help me, please??
Billy
-
Nov 27th, 2000, 09:59 AM
#7
Hyperactive Member
DATASOURCED should read DATASOURCE, this is the name of your recordset.
lgfgreport is the name of my report control.
EACHVALUEHERE should be replaced by your parameter values
(a different itteration loop could be used.
REPORTNAME is the path and name of your report.
Regards
Chris
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|