views:

273

answers:

2

Hi I am new to Crystal reports and now I have designed a report via Crystal reports 8.5 in vb6.0 and wanna to display the report.

I have picked up fields data from a View within my Data base but as you know Views have several records. I wanna to select a special record by a Primary key which is value of a textbox on my form.

please help me

+1  A: 

Add a parameter to the report and use the parameter in the select expert. Then, call SetParameterValue on the report document before loading.

dotjoe
could you please send me an example?
odiseh
A: 

Why not do a dynamic sql in you vb form picking the values from the textbox

 strSql =  "select blah from blah where blah ='" + txtBox.text +"'"

Then use then execute the query in a ado.recordset and pass that into a crystal reports application report object, using ttx files to define the data etc ...

Doing this you only have to worry about the dynamic sql from your vb form for parameter selection. The rest can be templated for any report.

Here is some code to start you off

Set AdoRs = New ADODB.Recordset
Set AdoRs = conn_rep.Execute(strSql)

Set CrRep = CrAppl.OpenReport(App.Path + "\crystal\" + CryReportName)

CrRep.Database.Tables(1).SetDataSource AdoRs, 3
CRViewer1.ReportSource = CrRep
CRViewer1.EnablePrintButton = True

CRViewer1.EnableExportButton = True
CRViewer1.EnablePrintButton = True
CRViewer1.viewReport
D0cNet