Filter Data In vb6 + Crystal Report 10

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • muddasirmunir
    Contributor
    • Jan 2007
    • 284

    #1

    Filter Data In vb6 + Crystal Report 10

    I am using vb6 and crystal report 10 (sql server 200 as database) to display record.

    I am using .rpt format for crystal report to display data. I am using net examples I am successfully able to display the data but unable to filter it.

    I want to know what is the syntax,formula for filtering the report using vb6.

    Here is the code I am using to display report.

    Code:
    Public CRReport As New CRAXDRT.Report
    Public CRApp As New CRAXDRT.Application
    Code:
    Public Sub CrysRpt(CrytalOCX As Object, RptPath As String, DBPath As String, DBPassword As String)
    
      '-Assign Path to Report
      Set CRReport = CRApp.OpenReport(App.Path & RptPath)
     
      On Error GoTo ExitLabel
      
      With CRReport '-// Log-On to Database with Password Protect
    
      '-//====================================
      .Database.Tables(1).SetLogOnInfo App.Path & DBPath, App.Path & DBPath, "", DBPassword
    
      End With
    
        With CrytalOCX
    
            'Set the source of Report viewer to the path of Report you made
            .ReportSource = CRReport
    
            'View/Display Report
            .ViewReport
    
        End With
    
        CRApp.CanClose
    
    Exit Sub
    
    ExitLabel:     MsgBox Err.Number & " " & Err.Description, vbCritical
    
    End Sub
    Calling Function to display report

    Code:
    On Error GoTo loaderr
    Screen.MousePointer = vbHourglass
    Call CrysRpt(CRViewer1, "\BanksInformation.rpt", "\My Bank.mdb", "asd987123")
    CRReport.ParameterFields(1).AddCurrentValue (250)
    Screen.MousePointer = vbNormal
    Exit Sub
    loaderr:
    MsgBox Err.Description
    Exit Sub
    End Sub
  • rekedtechie
    New Member
    • Feb 2012
    • 51

    #2
    your query is equal to
    select * from table1

    meaning you get all the data contained by table1..

    how did you connect your system in your database?..

    RDO, ADO or ADODC?

    if you can do some sql statement.. then maybe try this..

    'for example you have comboBoxFields

    dim strSql As String
    dim strFieldToFilte r As String
    strFieldToFilte r = "comboBoxFields .text"

    strSql = "SELECT " & strFieldToFilte r & " FROM your_table_name "

    'for example you used ADODC as your connection

    adodc1.refresh
    adodc1.doSql strSql

    Comment

    Working...