Print Problem in VB6.0 and Crystal Report 9.0 Environment

DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Print Problem in VB6.0 and Crystal Report 9.0 Environment

  1. #1
    Join Date
    Dec 2008

    Print Problem in VB6.0 and Crystal Report 9.0 Environment

    I have a problem when trying to print Crystal Report 9.0 (file.rpt) from VB 6.0.

    With the following VB code Crystal Report is loaded at “CRViewer91” control but when I click at the print button of “CRViewer91” then nothing to print.
    '1. Variable Declaration
    Dim Cn As ADODB.Connection
    Dim rs2 As ADODB.Recordset
    Dim Conn As String
    Dim crystlApp As New CRAXDRT.Application
    Dim crystlRpt As CRAXDDRT.Report
    '2. “CRViewer91” control inserted on VB form.
    '3. Write VB code for connection to Oracle 8 in Form Load
    Private Sub Form_Load() 
    Conn = "UID=abcde; PWD=youme; DRIVER={Microsoft ODBC for Oracle}; SERVER=;"
    Set Cn = New ADODB.Connection
    With Cn
    .ConnectionString = Conn
    .CursorLocation = adUseClient
    End With 
    End Sub
    '4. “Command1” control inserted on VB form
    '5. Wrote VB code to access Crystal Report 9.0(file.rpt) under Click event of command1 
    Private Sub Command2_Click()
    Set rs2 = Cn.Execute("select * from product, pricelist")
    Set crystlRpt = crystlApp.OpenReport("file.rpt", 1)
    crystlRpt.Database.SetDataSource rs2
    CRViewer91.ReportSource = crystlRpt
    CRViewer91.Zoom 80
    End Sub
    Anyone may kindly help to resolve the print problem
    Advance thanks for such act.
    Last edited by Hack; 12-29-2008 at 08:34 AM. Reason: Added Code Tags

  2. #2
    Join Date
    Apr 2007
    Sterling Heights, Michigan
    You do not "Execute" and SQL SELECT query. Execute is used for UPDATE, INSERT, DELETE, etc.

    For a SELECT query, you need to Open a recordset. I suspect nothing is printing because nothing is in the recordset you are trying to print.
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

Similar Threads

  1. Replies: 3
    Last Post: 05-20-2013, 06:57 AM
  2. Replies: 2
    Last Post: 08-07-2008, 08:32 AM
  3. how to use Vb6.0 & crystal report 10
    By query4u in forum VB Classic
    Replies: 1
    Last Post: 06-08-2006, 09:16 AM
  4. Working with Crystal Report Ver 10
    By AM003295 in forum VB Classic
    Replies: 4
    Last Post: 08-12-2005, 09:13 PM
  5. Replies: 2
    Last Post: 06-08-2002, 11:30 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center