Results 1 to 30 of 30

Thread: How do I pass a crystal report as argument?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2001
    Location
    Europe
    Posts
    289

    How do I pass a crystal report as argument?

    Im trying to pass a report to a function. If I define the argument as being CRAXDRT.Report none of the objects I have on my form are referenced anymore. Using Variant or Object does not work either. I can't actually use the name of the report either. Here's what I want to do:
    VB Code:
    1. Private Sub OneSub (param as Integer)
    2.  
    3. Dim InvM1 as MyCRReport1
    4. Dim InvM2 as MyCRReport2
    5. Dim InvM3 as MyCRReport3
    6.  
    7. Select Case param
    8. Case 0
    9. Call MyFunction(InvM1)
    10. Case 2
    11. Call MyFunction(InvM2)
    12. Case 3
    13. Call MyFunction(InvM3)
    14. End Select
    15. End Sub
    16.  
    17. Public Function MyFunction(InvMReport As ??)
    18.  
    19. End Function

    Any idea?

  2. #2

  3. #3

  4. #4

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2001
    Location
    Europe
    Posts
    289

    Re: How do I pass a crystal report as argument?

    Hi,

    Thing is I need to pass the whole report. I want to avoir doing the check in MyFunction so as to only have one block of code for InvMReport and not have 3 identical blocks of code for each report, if you see what I mean.

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2001
    Location
    Europe
    Posts
    289

    Re: How do I pass a crystal report as argument?

    It mentions Crystal but it really is a *general question* about how to pass a (Crystal) Object to a function.

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2001
    Location
    Europe
    Posts
    289

    Re: How do I pass a crystal report as argument?

    *bump*

  8. #8
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: How do I pass a crystal report as argument?

    What are MyCRReport1, 2 and 3?

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2001
    Location
    Europe
    Posts
    289

    Re: How do I pass a crystal report as argument?

    Crystal reports of the DSR type.

  10. #10
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: How do I pass a crystal report as argument?

    If I define the argument as being CRAXDRT.Report none of the objects I have on my form are referenced anymore.
    They are available, just not directly. You need to reference them in a different manner.

    If all reports have a Text Object, named txtHello, in the Report Header you could use this code to set its value.

    VB Code:
    1. Public Function MyFunction(InvMReport As CRAXDRT.Report)
    2.  
    3.     InvMReport.Sections("Section3").ReportObjects("txtHello").SetText "Hello World"
    4.  
    5. End Function

    Using Variant or Object does not work either.
    I don't know what you are doing but this works fine for me.

    VB Code:
    1. Public Function MyFunction(InvMReport As Object)
    2.     InvMReport.txtHello.SetText "Hello World"
    3. End Function

    If you want, post a sample project and I could take a look at it.

    Note: I have Crystal 8.5.

  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2001
    Location
    Europe
    Posts
    289

    Re: How do I pass a crystal report as argument?

    I know how to do this. I want to know how CR's are passed to functions. Please red the start of the thread again.

  12. #12
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: How do I pass a crystal report as argument?

    If you could explain yourself more clearly.

    How do I pass a crystal report as argument?
    Im trying to pass a report to a function.
    A CR Designer Form is not a Report, it is an object called ICRDesigner. You need to find which Library exposes that object but I doubt you will. It is probably only used internally in CRAXDDRT.

  13. #13

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2001
    Location
    Europe
    Posts
    289

    Re: How do I pass a crystal report as argument?

    Ok, I am trying to pass CR Designer object in that Designer part of the IDE. Not sure this is a form. Forms are located under Forms. My question is rather simple to understand as I explain it in the start of the thread. I have these CR Designer objects and need to pass them to a function but can't see which object type to use for the parameter in the function. Any idea?

  14. #14

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2001
    Location
    Europe
    Posts
    289

    Re: How do I pass a crystal report as argument?

    Anyone?

  15. #15

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2001
    Location
    Europe
    Posts
    289

    Re: How do I pass a crystal report as argument?

    *bump*

  16. #16

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2001
    Location
    Europe
    Posts
    289

    Re: How do I pass a crystal report as argument?

    Anyone?

  17. #17
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Thumbs up Re: How do I pass a crystal report as argument?

    Quote Originally Posted by MikeGarvin
    Anyone?
    If you are using the Crviewer then on the one form only it will work with one report, Please use the the crystal report control form using the function and the multiple report on the form.
    Because i used the crviewer on my form but it work only for one report at a time, I do not know why.
    After it i am using the crystal report control.
    So it's batter that use the crystal report control at the place of crviewer.

    I want to tell one thing more only posting the message on by one, posting anyone,anyone again and again it is not the solotion if you are not getting the solution then please try to get it on your hand.
    Last edited by shakti5385; Oct 21st, 2006 at 10:56 PM.

  18. #18

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2001
    Location
    Europe
    Posts
    289

    Re: How do I pass a crystal report as argument?

    Hi

    Not sure I understand what you are saying. It's not clear really. I seem to only get replies to my posts whenever I post them again. So posting again seems to be a 'solution'.

  19. #19
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Thumbs up Re: How do I pass a crystal report as argument?

    Private Sub OneSub (param as Integer)
    Please tell what is the param

  20. #20

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2001
    Location
    Europe
    Posts
    289

    Re: How do I pass a crystal report as argument?

    param is just an int i use to choose which report to use

  21. #21
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Re: How do I pass a crystal report as argument?


    Can you tell all the three report have the same work, or it is the one report or three different report

  22. #22

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2001
    Location
    Europe
    Posts
    289

    Re: How do I pass a crystal report as argument?

    Hi

    They are the same reports. Only the layouts differ.

  23. #23
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Thumbs up Re: How do I pass a crystal report as argument?

    Quote Originally Posted by MikeGarvin
    Hi

    They are the same reports. Only the layouts differ.
    Means there are three reports in your project, and you are using three same report on a single form.

  24. #24

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2001
    Location
    Europe
    Posts
    289

    Re: How do I pass a crystal report as argument?

    Yes. I want to be able to show any one of these reports on a form depending on what the user chooses.

  25. #25
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Thumbs up Re: How do I pass a crystal report as argument?

    VB Code:
    1. Private Sub OneSub(param As Integer)
    2. Dim S As String
    3. With CrystalReport1 'Crystal report component Name
    4. Select Case param
    5. .ReportFileName = App.Path & "\MyCRReport1.rpt" 'First report Name
    6. Call MyFunction(InvM1)
    7. Case 2
    8. .ReportFileName = App.Path & "\MyCRReport2.rpt" 'Second report Name
    9. Case 3
    10. .ReportFileName = App.Path & "\MyCRReport3.rpt" 'Third Report Name
    11. End Select
    12.  
    13. S = "{Table.Field}='" & Text1.Text1 & "'" 'Formula fro searching report.
    14.      .SelectionFormula S
    15.     .Action = 1 'Will Show The Report
    16. End With
    17. End Sub

    This is the code make by me using the crystal report component in the VB; using the CRViewer you are not able to call three reports on single form, So you have to use the crystal report component in your project for multiple report on single form.
    Read the crystal report tutorial from my signature and use above code for multiple reports on single form.

  26. #26

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2001
    Location
    Europe
    Posts
    289

    Re: How do I pass a crystal report as argument?

    Hi

    Not sure you answered my question.

    The objects I define at the start of the thread (,...) are embedded reports inside the VB IDE.

    I want to create code that will use only one object which corresponds to one of five reports a user can choose.

    To start my explanations again:

    I have 5 such reports: InvMain1, InvMain2, InvMain3, InvMain4, InvMain5. Below I created instances of each of these reports so they can be used in my code based on the user's choice.
    I want to use only one global object that will be the report users choose (e.g., invM below).
    I want to initialise this global object with the report people use so that I only use one object at a time, instead of repeating my code 5 times for each obkect (when I handle the report, like display it, print it...)

    How can I do this?

    Public invM As CRAXDRT.Report '***here
    Public invM1 As InvMain1
    Public invM2 As InvMain2
    Public invM3 As InvMain3
    Public invM4 As InvMain4
    Public invM5 As InvMain5

  27. #27
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Re: How do I pass a crystal report as argument?

    Did you try as I suggest to you in my Last post??

  28. #28

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2001
    Location
    Europe
    Posts
    289

    Re: How do I pass a crystal report as argument?

    Hi

    I tried, but for some reason I have 2 subreports on these 5 reports and I can access the sub objects on one but get errors on the other subreport. No matter how much I recreate these, I keep getting an object not defined error.

    Thanks.

  29. #29

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2001
    Location
    Europe
    Posts
    289

    Re: How do I pass a crystal report as argument?

    Hi

    Your post did not really help. I got a good reply from another poster in another thread.

    Sorry.

  30. #30

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2001
    Location
    Europe
    Posts
    289

    Re: How do I pass a crystal report as argument?

    Hi

    Like I say above I have 2 subreports, both located in their individual report footer. If I place subreport1 in footer a and subreport 2 in footer b, I get the error 438 'Object does not support this property or method' if I try and access the text boxes,... of subreport1, but don't get any errors when accessing the objects on subreport2. The incredible thing is if I swap the subreports around so that subreport1 is in footer b and subreport 2 in footer a, I now get the same errors on subreport2, which does not make any sense as subreport2 did not throw any errors in the 1st scenario.

    Anyone got any clues?

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