Results 1 to 14 of 14

Thread: *SOLVED*displaying crystal report within the mainform

  1. #1

    Thread Starter
    Addicted Member myrrdan's Avatar
    Join Date
    Nov 2002
    Location
    Alberta Canada
    Posts
    202

    *SOLVED*displaying crystal report within the mainform

    I'm new to crystal reports, so please keep the burns to a minimum lol.
    Anyways, i was wondering if its possible to display a crystal report within a form, rather than have it popup the form itself.
    This way they keep all the controls etc from the form, and can view the report, (with scrolling capabilities to move around the form)
    I'm modeling the program after a pre-existing program they had created around 92.
    They want to keep it as close to the original as possible so they don't have to learn anything new lol. They're busy enuf that they don't really have time for that.
    Now if it is possible, what components/references are needed?
    I want to try to figure it out myself, but in order to do that, i'ld like to at least know if its possible & where i should set my feet to start.
    Thanks.
    Last edited by myrrdan; Apr 7th, 2004 at 04:25 PM.
    Oooops.....theres another semi-colon in the wrong spot....

  2. #2
    Hyperactive Member ARPRINCE's Avatar
    Join Date
    Mar 2003
    Location
    Pinoy in NJ
    Posts
    381
    Yes, have the form as a child of the Main form. Components and references depends upon the CR version you have. If you are using CR9, then you need:

    - Crystal Report 9 ActiveX Designer Runtime Library (Reference)
    - Crystal Report Viewer Control 9 (component)

    You can also try Crystal's website for other samples on how to integrate your VB with CR.

  3. #3

    Thread Starter
    Addicted Member myrrdan's Avatar
    Join Date
    Nov 2002
    Location
    Alberta Canada
    Posts
    202
    hmm ok, i'll have to check it out.
    Thanks for the suggestions.

    Oooops.....theres another semi-colon in the wrong spot....

  4. #4

    Thread Starter
    Addicted Member myrrdan's Avatar
    Join Date
    Nov 2002
    Location
    Alberta Canada
    Posts
    202
    ok, seagates site is a pain..
    i wasn't able to find anything on embedding reports in visual basic.

    do i run the reports like i would a word document??

    i have no idea how to link the crystalviewer object to an actual file.
    there is no reportpath or anything.
    reportsource, but after set to the filepath of the report, it still comes empty. 0 records.
    Oooops.....theres another semi-colon in the wrong spot....

  5. #5
    Hyperactive Member ARPRINCE's Avatar
    Join Date
    Mar 2003
    Location
    Pinoy in NJ
    Posts
    381
    What your...CR Version? VB Version?

  6. #6

    Thread Starter
    Addicted Member myrrdan's Avatar
    Join Date
    Nov 2002
    Location
    Alberta Canada
    Posts
    202
    lol, sry my brain just isnt' with it this morning.

    vb 6, cr 8
    Oooops.....theres another semi-colon in the wrong spot....

  7. #7
    Hyperactive Member ARPRINCE's Avatar
    Join Date
    Mar 2003
    Location
    Pinoy in NJ
    Posts
    381
    CR8 uses a different approach (dll/ocx/ttx,etc.) on how to render reports on a form from CR9 so I may not be a lot of help to you.

    This could probably get you started.

    You can try using the advance search from CR.

    Hope this helps.

  8. #8

    Thread Starter
    Addicted Member myrrdan's Avatar
    Join Date
    Nov 2002
    Location
    Alberta Canada
    Posts
    202
    Thanks for the links. I downloaded the ex. but it hasn't helped in the slightest way lol.
    I'll just have to see if theres something else i can get to work. I have no idea how to link my crystalviewer to the report file.
    Nothing i do seems to work.
    Thanks though.
    Oooops.....theres another semi-colon in the wrong spot....

  9. #9

    Thread Starter
    Addicted Member myrrdan's Avatar
    Join Date
    Nov 2002
    Location
    Alberta Canada
    Posts
    202
    Ok, i'm at a loss. I can't get this to work no matter what i do, and its frustrating me.....
    This is the only code i have been ablet o put in that bloody works without crashing vb.

    Now i'm uinsg cr 8, vb 6.

    I have
    Crystal Report Viewer Conrol component inserted.

    Crystal report viewer control(vb6 one)
    Crystal report viewer control(cr 8 one)
    crystal report 8 activex designer runtime library.
    references.

    VB Code:
    1. Public Report1 As New CRAXDRT.Report 'CrystalReport1
    2.  
    3. frmMain.crvEnroll.ReportSource = Report1

    so how am i supposed to even set this stupid thing?
    the crvEnroll is the crystalviewer.
    I have to tell it to open the file
    app.path & "\files\EnrolledHorse.rpt"
    I can't find anything on this. Everythign i've found is either creating the bloody report, or opening & printing it outside of VB.

    Can anyone give me any information at all?
    Oooops.....theres another semi-colon in the wrong spot....

  10. #10
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758
    Crystal has to basic options to show reports within a VB application.

    One, everything is embedded with the VB project. You cannot modify the report outside your project. Change your report and you must recompile the EXE.

    Two. Create your reports outside of your VB project. Use Crystal's automation server to manipulate the report. Much like manipulating MS Office products from VB.

    I only work with option two. Here are the basics.

    Your project should reference the component Crystal Report Viewer Control (crviewer.dll) and the Crystal Report 8 ActiveX Designer Runtime Library.

    Add a CRViewer control to your Form.

    VB Code:
    1. 'its best to declare the following objCrystalReport variable globally and
    2. 'Create the instance when the application starts
    3. Dim objCrystalApp as CRAXDRT.Application
    4. Set objCrystalApp = New CRAXDRT.Application
    5.  
    6. Public Sub ShowReport(ByVal PathToReport as String )
    7.    Dim objReport as CRAXDRT.Report
    8.  
    9.    Set objReport = objCrystalApp.OpenReport(PathToReport)
    10.  
    11.    frmMain.crvEnroll.ReportSource = objReport
    12.    frmMain.crvEnroll.ViewReport
    13.  
    14.    Set objReport = Nothing
    15. End Sub
    16.  
    17. 'do this when your application shutsdown.
    18. Set objCrystalApp = Nothing

    Depending on your database and how you created your report you may need to set the Login Information. I will add a link to a thread I posted many moons ago. It may give you some ideas.

    Also, there are separate Help files for "developers". These are not accessible from within the Crystal product. There should be a sub-folder under Crystal installation location called ..\Developer Files.

  11. #11

    Thread Starter
    Addicted Member myrrdan's Avatar
    Join Date
    Nov 2002
    Location
    Alberta Canada
    Posts
    202
    well Bruce, got 1 thing to say..


    THANK YOU!!!!!!!!!!!!

    lol

    i owe you pal, like you wouldn't belive.
    I've been struggling with this since 8:40 this morning, its now 3:25!

    i was missing this from what i had tried....

    VB Code:
    1. Dim objCrystalApp As CRAXDRT.Application
    2.  
    3.  
    4. Set objCrystalApp = New CRAXDRT.Application
    5. Dim objReport As CRAXDRT.Report
    6.  
    7. Set objReport = objCrystalApp.OpenReport(strPath)

    thank you thank you thank you!
    Oooops.....theres another semi-colon in the wrong spot....

  12. #12
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758
    I just have one thing to say to you


    Go Canucks!!!!!!!!!!!!

    Oh and your welcome.

  13. #13

    Thread Starter
    Addicted Member myrrdan's Avatar
    Join Date
    Nov 2002
    Location
    Alberta Canada
    Posts
    202
    ROFL!!!

    Canucks fan huh..just when i thought you were normal ! lol
    j/k
    Flames Rules! (well not really, i dont' watch hockey, lol, but can't agree with everything)

    Oooops.....theres another semi-colon in the wrong spot....

  14. #14
    Addicted Member
    Join Date
    Jun 2006
    Posts
    219

    Re: *SOLVED*displaying crystal report within the mainform

    OK friends, can anybody help me with my CR - XI and VB6......Please

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