-
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:
Private Sub OneSub (param as Integer)
Dim InvM1 as MyCRReport1
Dim InvM2 as MyCRReport2
Dim InvM3 as MyCRReport3
Select Case param
Case 0
Call MyFunction(InvM1)
Case 2
Call MyFunction(InvM2)
Case 3
Call MyFunction(InvM3)
End Select
End Sub
Public Function MyFunction(InvMReport As ??)
End Function
Any idea?
-
Re: How do I pass a crystal report as argument?
You can pass it as string and based on string's value you would know which report run.
Just an idea. :)
-
Re: How do I pass a crystal report as argument?
-
Re: How do I pass a crystal report as argument?
@Martin:
I think it's more of VB question than Crystal... :confused:
-
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.
-
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.
-
Re: How do I pass a crystal report as argument?
-
Re: How do I pass a crystal report as argument?
What are MyCRReport1, 2 and 3?
-
Re: How do I pass a crystal report as argument?
Crystal reports of the DSR type.
-
Re: How do I pass a crystal report as argument?
Quote:
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:
Public Function MyFunction(InvMReport As CRAXDRT.Report)
InvMReport.Sections("Section3").ReportObjects("txtHello").SetText "Hello World"
End Function
Quote:
Using Variant or Object does not work either.
I don't know what you are doing but this works fine for me.
VB Code:
Public Function MyFunction(InvMReport As Object)
InvMReport.txtHello.SetText "Hello World"
End Function
If you want, post a sample project and I could take a look at it.
Note: I have Crystal 8.5.
-
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.
-
Re: How do I pass a crystal report as argument?
If you could explain yourself more clearly.
Quote:
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.
-
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?
-
Re: How do I pass a crystal report as argument?
-
Re: How do I pass a crystal report as argument?
-
Re: How do I pass a crystal report as argument?
-
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.
-
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'.
-
Re: How do I pass a crystal report as argument?
Quote:
Private Sub OneSub (param as Integer)
Please tell what is the param :confused:
-
Re: How do I pass a crystal report as argument?
param is just an int i use to choose which report to use
-
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
-
Re: How do I pass a crystal report as argument?
Hi
They are the same reports. Only the layouts differ.
-
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.
-
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.
-
Re: How do I pass a crystal report as argument?
VB Code:
Private Sub OneSub(param As Integer)
Dim S As String
With CrystalReport1 'Crystal report component Name
Select Case param
.ReportFileName = App.Path & "\MyCRReport1.rpt" 'First report Name
Call MyFunction(InvM1)
Case 2
.ReportFileName = App.Path & "\MyCRReport2.rpt" 'Second report Name
Case 3
.ReportFileName = App.Path & "\MyCRReport3.rpt" 'Third Report Name
End Select
S = "{Table.Field}='" & Text1.Text1 & "'" 'Formula fro searching report.
.SelectionFormula S
.Action = 1 'Will Show The Report
End With
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.
-
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
-
Re: How do I pass a crystal report as argument?
Did you try as I suggest to you in my Last post??
-
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.
-
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.
-
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?