If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Crystal Reports > Visual Basic codes to execute Crystal Reports ver.11

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-17-11, 03:26
LimaCharlie LimaCharlie is offline
Registered User
 
Join Date: Oct 2005
Posts: 119
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:

Code:
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
    rpt.PrintReport
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?

Thanks.
Reply With Quote
  #2 (permalink)  
Old 01-18-11, 02:39
LimaCharlie LimaCharlie is offline
Registered User
 
Join Date: Oct 2005
Posts: 119
Got this already. For those who might ask the same question. Here's my code that works:

Code:
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

rpt.ViewReport
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.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On