Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2005

    Unanswered: Visual Basic codes to execute Crystal Reports ver.11

    I was previously using Crystal report ver.7. I’m executing the reports thru Visual Basic Codes:

    Private Sub Call_Report
        rpt.Connect = “ODBC;DATABASE=DBName;UID=username;PWD=password;DSN=ODBC_DataSourceName” ‘rpt is the name of the crystal report control
        rpt.ReportFileName = sReportPath ' report path and report name
        rpt.Destination = crptToWindow ' print to file
        rpt.SQLQuery = “select * from …..”
        rpt.WindowState = crptNormal
        rpt.WindowShowZoomCtl = True
        rpt.DiscardSavedData = True
    End Sub
    Now, I converted my reports into Crystal Report ver.11. The code above does not work anymore. What is the correct code so I can call my reports from Visual Basic?


  2. #2
    Join Date
    Oct 2005
    Got this already. For those who might ask the same question. Here's my code that works:

    Dim App1 As New CRAXDRT.Application
    Dim Report As New CRAXDRT.Report
    App1.LogOnServer "PDSODBC.DLL", "DSNName", "DBname, "user_name", "user_pwd"
    Set Report = App1.OpenReport(report_path)
    Report.SQLQueryString = "select * frrom...."
    rpt.ReportSource = Report
    Got another question, I hope someone can answer. How do I display my report in a separate window or in a new window? What's the VB code for that? Thanks.

Posting Permissions

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