1
votes

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

I have picked up fields data from a View within my database but as you know Views have several records.

I want to select a special record by a Primary key which is value of a textbox on my form.

2

2 Answers

1
votes

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

1
votes

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