Hi Ken,
I am using MS SQL 2000 for the backend and am working with a 3-tier vb app. The customer table has the following data structure: CustomerId, CustomerName, CustAddress, City, State, RegionId, CountryId...
Below is the code for creating a recordset based on a userdefined filter string and passing it to the Report
'****** Form #1 ***********
Public Sub DoPrint()
Dim strReportName As String
Dim rs As Recordset
Dim cRsFactory As clsRsFactory
If mfStdPrint Is Nothing Then
Set mfStdPrint = New fStdPrint
End If
mfStdPrint.Show vbModal
If mbPrint Then
If mfViewReport Is Nothing Then
Set mfViewReport = New fViewReport
End If
strReportName = App.Path "AgentReport.rpt"
'get recordset based on filter
mstrFilter = "CITY LIKE 'Los Angeles' AND StateProvince LIKE 'CA' AND Inactive=0"
Set cRsFactory = New clsRsFactory
Set rs = cRsFactory.Create(eRsAgent, mstrFilter)
'open report viewer - call form #2
Call mfViewReport.OpenReport(strReportName, rs)
End If
End Sub
'****** Form #2 ***********
Private crApplication As New CRAXDDRT.Application
Private crReport As CRAXDDRT.Report
Private Sub Form_Load()
'specify the report to preview
CRViewer.ReportSource = crReport
'View the Report
CRViewer.ViewReport
End Sub
Public Sub OpenReport(ByVal strReportName As String, ByVal rs As Recordset)
If rs.RecordCount < 1 Then
MsgBox "No data to print."
Exit Sub
End If
Set crReport = crApplication.OpenReport(strReportName)
'Pass a recordset into a report at rum-time
'the report was created with Active Data Driver
crReport.DiscardSavedData
'pass recordset to report
crReport.Database.SetDataSource rs, 3
End Sub
The key functinality here is to print a report that consist of only filtered data. How do I implement a alternative solution with what i have here?