PDA

Click to See Complete Forum and Search --> : Crystal Report


jpark
Jul 28th, 1999, 02:10 AM
Hi,

How do you send a variable from VB app. to crystal report so that it takes as criteria for filtering record for the report?

Do I have to use formula or parameter, or something else?

I created formula called @OrderID, which formula text is "{tblOrder.OrderID} = 50757", then on select tab on report Expert, I set @OrderID is true.

Private Sub cmdView_Click()
CrystalReport1.ReportFileName = App.Path & "\test.rpt"
CrystalReport1.Formulas(0) = "OrderID = {TBLORDER.ORDER_ID}= " & Text1

Form1.CrystalReport1.Destination = 0
Form1.CrystalReport1.Action = 1
End Sub

I do a lot of report /w access, but never have done /w CR. Please help me!

Thank you in advance
Joon

FirstKnight
Jul 28th, 1999, 11:08 AM
First of all if you are not allready using Crystal Reports 6.0 I suggest you download it from http://www.seagate.com . Trust me it works much better than the one that ships with VB5. Then all you have to do is create you're report (read the help files to find out how) and in the load event of the preview window that it creates write something like this:

Private Sub Form_Load()

Dim Report As New CrystalReport1

Dim dbs As Database
Dim rs As DAO.Recordset
Set dbs = OpenDatabase(strTarget)
Set rs = dbs.OpenRecordset(strExpTable)

Report.Database.SetDataSource rs
Report.Database.Verify

CRViewer1.ReportSource = Report
CRViewer1.ViewReport

If you are using a ADO type database it would look like this:

Private Sub Form_Load()

Dim Report As New CrystalReport1

Dim rs As New ADOR.Recordset

rs.Open "SELECT * from Customer WHERE country = 'USA'", _
"DSN=Xtreme sample data;", adOpenKeyset

Report.Database.SetDataSource rs

CRViewer1.ReportSource = Report
CRViewer1.ViewReport

End Sub

And that is all there is to it. Read the help file that comes with version 6, it explains a lot.

jpark
Jul 28th, 1999, 08:12 PM
I got the answer from book.

Thanks anyway.