CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2008
    Posts
    19

    Visual basic 6 with crystal report

    I Wish to pass parameter in Crystal Report. I have Access data base one table named

    student. I with to select range of data's from that table field named "rno"

    i am using visual basic 6

    I used following code to view crystal report
    ================================================
    Set rs = New ADODB.Recordset
    modConnection.opendb
    rs.Open "select * from STUDENT_M order by rno", cn, adOpenStatic, adLockPessimistic
    Report.Database.SetDataSource rs
    Screen.MousePointer = vbHourglass
    CRViewer1.ReportSource = Report
    CRViewer1.ViewReport

    Screen.MousePointer = vbDefault


    ==========================================
    I am new to crystal report. please guide me how to use parameter in crystal report.


    a.Senthil kumar.

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Visual basic 6 with crystal report

    Something like this should work:
    Code:
    Set m_Application = New CRAXDRT.Application
    Set m_Report = New CRAXDRT.Report
    Set m_Report = m_Application.OpenReport(App.Path & "\ReportName.rpt", 1)   
        m_Report.EnableParameterPrompting = False
         
        Set m_Parameters = m_Report.ParameterFields
        
        For cnt = 1 To m_Parameters.Count
            Set m_Parameter = m_Parameters.item(cnt)
            If m_Parameter.name = "{?testcode}" Then
               m_Parameter.AddCurrentValue "12345"
            End If
        Next
        
        
        frmReportView.CRViewer1.ReportSource = m_Report
        frmReportView.CRViewer1.ViewReport
        
        frmReportView.Show
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured