Results 1 to 4 of 4

Thread: VB.Net / Crystal reps - one display form

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2002
    Location
    Brisbane Australia
    Posts
    150

    Angry VB.Net / Crystal reps - one display form

    I have one display form to display my Crystal Rpeorts for my VB.NET app called CRDisplay.vb. I want to use this one form to display any number of reports I have set up such as CRMembers.rpt or CRStudents.rpt etc but I don't know how to pass this as a parameter to the CRDisplay form.

    if i hard code the report name as in the code below it works fine (naturally)

    What I want to do is pass the CR Report name to this form from a user report selection form so I only have the one display form rather than a separate display form for each report !! I have tried different ways but can't seem to get the name of the report file into this form

    Any help woould be greatly appreciated.

    Public Class CRDisplay
    Inherits System.Windows.Forms.Form
    Dim rpt1 As New CRmembers() 'this works - see below ****
    ' or dim rpt1 as CRStudents () 'if this is the report I want

    #Region " Windows Form Designer generated code "
    #End Region


    Private Sub CRDisplay_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load

    CRViewer.ReportSource = rpt1 ' this works - see above ****


    End Sub
    End Class

  2. #2
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    From what you have written I think you are going to create a new instance of a crystal reports just by passing its name. This works for me;
    VB Code:
    1. Dim rpt As CrystalDecisions.CrystalReports.Engine.ReportDocument
    2. Try
    3.         rpt = Activator.CreateInstance(Type.GetType("Namespace.Reportname"))
    4. ' Here you pass the name of your report along with the root namespace of it,
    5. 'no problem you should have here.
    6.       Catch ex As Exception
    7.            MessageBox.Show("Error creating: " + ex.ToString())
    8. End Try
    9.  
    10. 'here you can do what ever you want with your report :p
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  3. #3
    Junior Member
    Join Date
    Sep 2002
    Location
    Florida
    Posts
    24
    assign it when creating the instance of the new display form:


    Dim myreport As New CRmembers()


    Dim newform As New CRDisplay ()
    newform.CrystalReportViewer1.ReportSource = myreport


    newform.Show()

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jun 2002
    Location
    Brisbane Australia
    Posts
    150

    Thankyou

    I was missing the point - keep thinking old VB without being able to have multiple instances of the one form - still coming to grips with .NET

    thanks again

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