Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using CR8.5 with a Data Environment that requires a Parameter

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I'm wondering if i can get a little help here

i'm trying to make a report with CR8.5 that will use a MS Data Environment as the Source

however this data environment requires 1 parameter to be able to run its task.
i can send the parameter fine and i checked the DE to make sure it works and it does.
when i go to make the report the report can't be made because of the parameter not defined
sooooo i went to crystal and they said

"The solution is to hard code a value in the SQL when the Command object is first created and create the Report off the Data Environment (DE) as usual. This is so Crystal Reports is able to fire the DE SQL and build the reports data definition file from the returned resultset.

After the report has been created go back to the command object and substitute the hard coded value for a '?' which will recreate the parameter. "


i did what they said and now i made the report....but here is the main problem
now the report will only pull the information that is equal to the parameter hard code value and won't take the information from the DE

example

hard code sql:
select custinfo.* From CustInfo where (Customer = 'none')

the real sql i need to use:
select custinfo.* From CustInfo where (Customer = ?)

? = custinfo

the code in the form to send the parameter

dataenvironment1.connection1.open
dataenvironment1.command1 text1.text

then open the form to view the report
load form2
form2.show


got any ideas please help if you can
 
I've never used the data environment, but I've heard its slow. What I have done before is passed recordsets to cr8 using ado in code. Here you can just pass a variable and build your recordset from it and then pass it to your report. Just an idea, here's the code..

'this code sample illustrates how to pass two records from an ADO recordset, to a report
'that has two formula fields (in the Details section) and NO database connection.

Dim Report As New CrystalReport1
Dim ADOrs As ADODB.Recordset
Dim DBLocation As String


Private Sub Form_Load()

'Show the common dialog to select the sample database
CommonDialog1.ShowOpen

'binds the ADO recordset object to ADO recordset variables
Set ADOrs = CreateObject("adodb.recordset")

'sets cursor location for recordset
'the CursorLocation, CursorType and LockType in this sample are the recommeneded
'choices when working with the Crystal Reports active data driver.
ADOrs.CursorLocation = adUseClient

'open the recordset
ADOrs.Open "select * from customer", "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & CommonDialog1.FileName & ";Persist Security Info=False", adOpenDynamic, adLockBatchOptimistic

'add the ADO recordset to the report
Report.Database.AddADOCommand ADOrs.ActiveConnection, ADOrs.ActiveCommand

'these variables will be used in the Check method to validate the formula fields
Dim x As Boolean
Dim y As String

'Note: once the ADO recordset is added to the report it is referenced as a table object within
'the report

'pass the first field name from the added ADO recordset to the first formula field in the report
Report.FormulaFields(1).Text = Report.Database.Tables(1).Fields(1).Name
'match the field name from the ADO recordset for a column header
Report.Text1.SetText ADOrs.Fields(0).Name
'validate the formula field
Report.FormulaFields(1).Check x, y

'pass the second field name from the added ADO recordset to the second formula field in the report
Report.FormulaFields(2).Text = Report.Database.Tables(1).Fields(3).Name
'match the field name from the recordset for a column header
Report.Text2.SetText ADOrs.Fields(2).Name
'validate the formula field
Report.FormulaFields(2).Check x, y


Screen.MousePointer = vbHourglass
CRViewer1.ReportSource = Report
CRViewer1.ViewReport
Screen.MousePointer = vbDefault

End Sub

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top