Open Crystal reports file with Visual Basic application

Posted on 2006-03-24
Last Modified: 2013-11-25
   I have created a crystal reports file for my users. I want them to be able to click on an executable and be able to open up the file withou worrying about the login or the server name.
I setup a dsn on their pc so everything should be transparent.
This the code i have now

    Set Report = Appl.OpenReport("c:\crystal_file.rpt")
    Report.Database.LogOnServer "p2sodbc.dll", "DatabaseName", "DatabaseName", "username", "password"
    CRViewer1.ReportSource = Report

I get a "Server has not yet been opened" error message from crystal reports.

Can anybody help me to get this to work?
Question by:dayiku
    LVL 3

    Expert Comment

    I used to have the same problem.

    Check out the client PC and ensure that you have the p2sodbc.dll. Or ensure that you have the crystal runtime on the client PC.

    Author Comment

    I tried it on my pc and it doesn't work. Do you know why?
    I need to get it to work on my pc before i give it to the client.
    LVL 3

    Expert Comment

    Check out the windows\crystal folder to see if the above dlls are there/

    Author Comment

    I found the dll in the system folder. Should i put it in the crystal folder?
    LVL 3

    Accepted Solution

    No. I did not do that. BTW, check out the crystaldecision website, I got my solution from there.

    Author Comment

    This is what i found on the crystal decision website.
    Crystal 8 has a know problem with visual basic.

    To work around this issue, use the 'SetLogonInfo' method off the 'Tables' object rather than the 'LogonServer' method. For example:

    'Sample Code for SetLogonInfo
    Report.Database.Tables(1).SetLogOnInfo "server", "database", "UID", "PWD"

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Introduction In a recent article ( for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
    Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
    This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA.…

    737 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

    22 Experts available now in Live!

    Get 1:1 Help Now