CR Report Wizard in VB 6.0... 
Author Message
 CR Report Wizard in VB 6.0...

Hello everyone,

I'm using VB 6.0 and Crystal 8.5 and the CR Report Wizard.
I'm wondering if I can limit the data that the report wizard will finally
produce by connecting the reports recordset via SetDataSource before passing
it to the wizard? I have tried this, with no success. My code is below. If
this can or can't be accomplished this way, I would sure appreciate some
guidance.

Thanks, Rich.

'---------------------------------------------------------------------------
-------------------

'****************************
'* Here's where it starts
'****************************
Private Sub mnuHelpReportsQuickReport_Click()
Dim ReportMod As ReportModule
Dim stabTableName As String
Dim RptConn As ADODB.Connection
Dim AWhereClause As String
Dim AValue As Integer
On Error GoTo HandleErrors
  stabTableName = PVExp.TreeView.Key
  Set ReportMod = New ReportModule
  Set RptConn = New ADODB.Connection
  RptConn.ConnectionString = gsConnect
  RptConn.CursorLocation = adUseClient
  ReportMod.ConnectByConnection RptConn
  AValue = 871
  AWhereClause = "where SUBLOC_Id = " & AValue
  ReportMod.ShowLWQuickReport stabTableName, AWhereClause
Exit Sub
HandleErrors:
  MsgBox CStr(Err.Number) & ":  " & Err.Description, vbInformation, "Report
Error"
End Sub

'****************************
'*  Gets things set up for the wizard
'****************************
Public Sub ShowLWQuickReport(ByVal ATable As String, _
                                                     Optional ByVal
AWhereClause As String)
Dim App As CRAXDRT.Application
Dim AReport As CRAXDRT.Report
Dim AWizard As CRStandardWizard
  Screen.MousePointer = vbHourglass
  Set App = New CRAXDRT.Application
  Set AReport = App.NewReport
  ConnectQuickReport AReport, ATable, AWhereClause

  Set AWizard = New CRStandardWizard
  Set AWizard.CrystalReport = AReport
  Screen.MousePointer = vbDefault
  AWizard.DisplayReportWizard
End Sub

'****************************
'* Connects the Data Source
'****************************
Private Sub ConnectQuickReport(ByVal AReport As CRAXDRT.Report, _
                                                    ByVal ATable As String,
_
                                                    Optional ByVal
AWhereClause As String)
Dim RptRS As ADODB.Recordset
Dim RptSQL As String
On Error GoTo HandleErrors
  Screen.MousePointer = vbHourglass
  If AWhereClause = vbNullString Then
    Select Case m_ConnectType
      Case csConnection
        AReport.Database.AddOLEDBSource m_Connection, ATable
      Case csLocation
        AReport.Database.AddOLEDBSource m_Connection, ATable
    End Select
  Else
    '*******************************
    '*  Set up the record set
    '*******************************
    Set RptRS = New ADODB.Recordset
    RptSQL = "Select Subloc_Id From " & ATable & " " & AWhereClause
    RptRS.CursorLocation = adUseClient
    RptRS.Open RptSQL, m_Connection, adOpenStatic, adLockOptimistic
    AssignReportTables AReport, ATable
    Select Case m_ConnectType
      Case csConnection
        If AReport.HasSavedData Then
          AReport.DiscardSavedData
        End If
        '******************************
        '*  Assign the recordset and Read the
        '*  data
        '******************************
        AReport.Database.SetDataSource RptRS
        AReport.ReadRecords
      Case csLocation
        If AReport.HasSavedData Then
          AReport.DiscardSavedData
        End If
        'AReport.Database.SetDataSource RptRS
        'AReport.RecordSelectionFormula = RptSQL
        AReport.SQLQueryString = RptSQL
        'AReport.ReadRecords
    End Select
  End If
  Screen.MousePointer = vbDefault
Exit Sub
HandleErrors:
  Screen.MousePointer = vbDefault
  MsgBox CStr(Err.Number) & ":  " & Err.Description
End Sub



Mon, 07 Mar 2005 22:27:38 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. CR 6.0 Report upgraded to CR 7.0 report has formatting issues

2. Upgraded CR 6.0 Report to CR 7.0 got formatting issues

3. CR Intranet reporting and VB 6.0

4. VB 6.0 : CR 7.0 - [Cancel] CR

5. Filter dates between VB 6.0 and CR 6.0 from *.qry

6. Report Options in CR 6.0

7. Creating report with CR 6.0

8. Dlls for report viewer in CR 6.0

9. !! Blank Details on Report (using CR 6.0)

10. Black Line Printing Reports From the ActiveX Smart Viewer (CR 6.0)

11. 1 * bxfcLDMXT-Odbc Error occurs while opening a CR 6.0 report in the Preview window

12. Odbc Error occurs while opening a CR 6.0 report in the Preview window

 

 
Powered by phpBB® Forum Software