Wednesday, March 28, 2012

New to Crystal Reports

Hi,

I am new to crystal Reports. I am on a project to migrate database from MS Access to MS SQL 2000 for a project which is in VB6. We are using Crysal Report 7.0. Earlier version reports in MS Access were working fine and used SelectionFormula. I want to use the same thing in my next MS SQL version also. But I don't know where and how to begin.

In my project, user will chose company (from combo box), subcompany (combo box), location (combo box), Item Category (combo box) and press the Report button which triggers the below code. Here each company name, subcompany name, location, item category were from different master tables and list of items for them is in another table. In report I need to list items for user selected company, subcompany, location, item category.

The code is like this:

Private Sub cmdAssetRpt_Click()
Dim crptApp As New CRAXDRT.Application
Dim crptRep As New CRAXDRT.Report

Set crptRep = crptApp.OpenReport(App.Path & "\Reports\AssetDetailsLocationWiseRpt.rpt")
crptRep.RecordSelectionFormula = "{LocationMaster.LocationName}='" & (cboLocation.Text) & _
"'and {ItemDetails.ItemGroupCod}='" & strItemgrpCode & "'"
If frmReports.CRViewer1.IsBusy = False Then
frmReports.CRViewer1.ReportSource = crptRep
frmReports.CRViewer1.DisplayGroupTree = False
frmReports.CRViewer1.ViewReport
End If
Exit Sub
End If
End sub

I was surprised how SelectionFormula will query my database to filter only requiered data and send it to report?
I need complete info about Reports, SelectionFormula, Tips, sample code anything. Plese help me. its urgent for me. Only this work is leftout in my project!!query is inside report, and selection formula just filters records returned by the query.sql

No comments:

Post a Comment