i am using vb6.0 and crystal report11 and MS ACCESS database how to create a crystal report at run time from a vb form i dont have any idea regarding this please give some suggestions or code would be very helpful to me

Recommended Answers

All 6 Replies

this is wht i did in my project

first design ur report thru crystal reports

in a form(vb) u just add the crviewercontrol

then write the code using this logic

Private Sub cmdReportOK_Click()
Dim m_Report As CRAXDDRT.Report
Dim m_Application As New CRAXDDRT.Application
Set m_Report = Nothing
Set m_Report = m_Application.OpenReport(App.Path + "\myreport.rpt", 1)
    m_Report.ParameterFields.Item(1).AddCurrentValue cmbReport.Text
    m_Report.ParameterFields.Item(2).AddCurrentValue dtpFrom.Value
    m_Report.ParameterFields.Item(3).AddCurrentValue dtpTo.Value
With CRViewer1
    .EnableExportButton = True
    .EnablePrintButton = True
    .EnableCloseButton = True
    .ReportSource = m_Report
    .ViewReport
End With
End Sub

What reference needs to be added to VB to use the CRAXDDRT add it?

Thanks.
phil.sloan@dsm.com


this is wht i did in my project

first design ur report thru crystal reports

in a form(vb) u just add the crviewercontrol

then write the code using this logic

Private Sub cmdReportOK_Click()
Dim m_Report As CRAXDDRT.Report
Dim m_Application As New CRAXDDRT.Application
Set m_Report = Nothing
Set m_Report = m_Application.OpenReport(App.Path + "\myreport.rpt", 1)
    m_Report.ParameterFields.Item(1).AddCurrentValue cmbReport.Text
    m_Report.ParameterFields.Item(2).AddCurrentValue dtpFrom.Value
    m_Report.ParameterFields.Item(3).AddCurrentValue dtpTo.Value
With CRViewer1
    .EnableExportButton = True
    .EnablePrintButton = True
    .EnableCloseButton = True
    .ReportSource = m_Report
    .ViewReport
End With
End Sub

first do u have the crviewer in ur components
it will take all the references automatically

otherwise you just select all the related references to crystal reports

let me know wht version of cr u r using

How show report ,,,usin vb6.0 and CRYSTAL REPORT 9 and MS ACCESS database

first design the report in crystal reports
add a crystal report viewer in ur form
write the code like in the 2nd post of this thread..

try first if u hav any prob come back to me

Once the report is filled with data the report will be automatically shown.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.