call a crystal reports 4.6 from vb6

Posted on 2009-02-17
Last Modified: 2013-11-28
Hi everybody,
I want to print or preview a report made with crystal reports 4.6 by clicking on command button on a vb6 form.  I want to use version 4.6 of crystal report (don't want to update).  I use an access database (called mydb.mdb).
So I creat a crystal report (called myreport.rpt), a crystal report control ( called CrystalReport1) on the vb6 form and a command button with the associated code:

CrystalReport1.ReportFileName = Dir1.Path & "\myreport.rpt"
CrystalReport1.DataFiles(0) = Dir1.Path & "\mydb.mdb"
CrystalReport1.DiscardSavedData = True
CrystalReport1.action = 0

I get error 20536 : "Unable to connect: incorrect log on parameters"

I tried to use these additional commands:
id = CrystalReport1.LogOnServer("p2sodbc.dll", "access", "mydb", "Admin", "")
CrystalReport1.Connect = "dsn=odbc;uid=admin;pwd=;dsq=mydb.mdb"
CrystalReport1.LogonInfo(0)= "dsn=access;uid=admin;pwd=;dsq=mydb.mdb"

But none of these solve the problem. And I am not shure that the arguments I wrote are good.

I know this question is already asked on this website, but everytime, the solution is a link like and when I try to follow this link, I am redirected on another website :

Thanks in advance for your help.
Question by:gastroju
    LVL 4

    Accepted Solution

    I bought (for $16) Ken Hamady's guide to Crystal reports in VB6.  It showed me exactly what to do to get VB communicating with Crystal.
    LVL 100

    Expert Comment


    Author Comment

    Thanks for your answers.
    mlmcc, I tried the sample code in but i can't execute  the "report1.rpt" file with crystal report (error message: unable to load report). So I ceated another report based on the cost.mdb database with one field ( And when I launched the vb programm, I got the error 20536 unable to connect : incorrect logon parameters...

    spangdelta, does Ken hamady's guide answered your questions about version 4.6 of crystal reports?

    Thanks for your help

    Featured Post

    Courses: Start Training Online With Pros, Today

    Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

    Join & Write a Comment

    Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
    A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
    Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
    With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now