Results 1 to 6 of 6

Thread: Open Crystal Report using Visual Basic

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2001
    Posts
    149

    Question Open Crystal Report using Visual Basic

    Hi,

    How can I open the crystal report using visual basic ?
    I have the direct path of the database. I am using Crystal Report ocx. I wish to specify the direct path of the database for previewing the report rather than using ODBC. Currently, this is how I do it:

    PrintIt.ReportFileName = App.Path & "\REPORTS\Report.RPT"
    PrintIt.WindowTitle = "Daily Report"
    PrintIt.RetrieveDataFiles
    PrintIt.DataFiles(0) = "c:\DB.mdb"
    PrintIt.Action = 1

    It seem to work alright but when I set a password to the database, the code above don't work. I have the password with me but how can I specify the password in the path?

    I am using Crystal Report 4.5, Visual Basic 6, Access97.

    Thanks in advance.

  2. #2
    Addicted Member diban's Avatar
    Join Date
    Aug 2002
    Location
    IN
    Posts
    152
    Hi

    I think you are complicating a very simple procedure.

    First all, create a datasource object to connect to your database, use dataenvironment or ado control (hope you know how to do this).

    Next, add the Crystal Report Viewer Control from the Component panel (Ctrl+T).

    Drag and drop this component from the tool bar to your project. Most cases you can simply follow the instructions. Connect to the the database using the datasource object.

    Rest should be fine, I hope.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Sep 2001
    Posts
    149
    Hi Diban,
    Thanks for replying. I have a question here, so if I use the
    ADO data control to bound the crystal report, when I am
    designing the report, should I link up my report using ODBC
    or datafile at the crystal report side ? Or it does not matter
    either one?

    By the way, can you post some simple code that is need for the
    properties of the ADO control as I seldom use data control especially bound to a report.

    Thanks again.
    Last edited by dollygoh; Nov 29th, 2002 at 01:56 AM.

  4. #4
    Addicted Member diban's Avatar
    Join Date
    Aug 2002
    Location
    IN
    Posts
    152
    Hi

    As I understand, you want to use the report from within your application. In this case FORGET DOING ANYTHING WITHIN CR as VB will allow you to generate a complete customized report using the CR!!!!

    So with that in mind, I suggest you start with data Environment. Insert this object from Component's Designer Panel. From the project menu select the add data environment option. In the Data Environment page right click on the Connection1 text and select properties. I suggest you select microsoft jet 4.0... option in the provider tab. From the connection tab select the database you want. Test this connection. VOILA!. You have created a data connection. Now add command to the dataenvironment by right clicking on the Data Environment Page(DE). To keep it simple, select Command Type (in properties of command) as cmdTable and type the name of your table in CommandText.

    If you get a plus sign next to the Command1 in DE then you have successfully created a recordset object.

    You can use this object now in your program to manage your data.

    Rest will leave it up to you to explore!!! Happy learning

  5. #5
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758
    I have version 8.0 so I dont know if the following applies to version 4.5.

    What type of security does your Access database use? User level, database level or both

    User Level - then just set the Password property.
    Database level - then you need a linefeed character (chr10) followed by the database level password.
    CrystalReport1.Password = Chr(10) & "dbpassword"

    If the Access database contains both types of security then use the user password followed by the linefeed character and then database password:

    CrystalReport1.Password "userpassword" & Chr(10) & "dbpassword"

    Database-level security can also be handled by assigning the password to the Password parameter of the LogOnInfo method.

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Sep 2001
    Posts
    149

    Thumbs up

    Hi,

    Thanks all for replying. I have tried brucevde's method and it works.

Posting Permissions

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



Click Here to Expand Forum to Full Width