|
-
Oct 11th, 2006, 10:38 AM
#1
Thread Starter
Hyperactive Member
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?
-
Oct 11th, 2006, 10:43 AM
#2
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.
-
Oct 11th, 2006, 10:47 AM
#3
Re: How do I pass a crystal report as argument?
-
Oct 11th, 2006, 10:48 AM
#4
Re: How do I pass a crystal report as argument?
@Martin:
I think it's more of VB question than Crystal...
-
Oct 11th, 2006, 10:49 AM
#5
Thread Starter
Hyperactive Member
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.
-
Oct 11th, 2006, 10:53 AM
#6
Thread Starter
Hyperactive Member
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.
-
Oct 12th, 2006, 04:11 AM
#7
Thread Starter
Hyperactive Member
Re: How do I pass a crystal report as argument?
-
Oct 12th, 2006, 09:48 AM
#8
Re: How do I pass a crystal report as argument?
What are MyCRReport1, 2 and 3?
-
Oct 12th, 2006, 10:06 AM
#9
Thread Starter
Hyperactive Member
Re: How do I pass a crystal report as argument?
Crystal reports of the DSR type.
-
Oct 12th, 2006, 12:24 PM
#10
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:
Public Function MyFunction(InvMReport As CRAXDRT.Report)
InvMReport.Sections("Section3").ReportObjects("txtHello").SetText "Hello World"
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:
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.
-
Oct 12th, 2006, 12:28 PM
#11
Thread Starter
Hyperactive Member
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.
-
Oct 12th, 2006, 03:13 PM
#12
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.
-
Oct 16th, 2006, 04:37 AM
#13
Thread Starter
Hyperactive Member
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?
-
Oct 17th, 2006, 04:41 PM
#14
Thread Starter
Hyperactive Member
Re: How do I pass a crystal report as argument?
-
Oct 19th, 2006, 12:11 PM
#15
Thread Starter
Hyperactive Member
Re: How do I pass a crystal report as argument?
-
Oct 21st, 2006, 01:53 PM
#16
Thread Starter
Hyperactive Member
Re: How do I pass a crystal report as argument?
-
Oct 21st, 2006, 10:52 PM
#17
Re: How do I pass a crystal report as argument?
 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.
-
Oct 22nd, 2006, 05:28 AM
#18
Thread Starter
Hyperactive Member
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'.
-
Oct 22nd, 2006, 06:55 AM
#19
Re: How do I pass a crystal report as argument?
Private Sub OneSub (param as Integer)
Please tell what is the param
-
Oct 22nd, 2006, 07:01 AM
#20
Thread Starter
Hyperactive Member
Re: How do I pass a crystal report as argument?
param is just an int i use to choose which report to use
-
Oct 22nd, 2006, 10:17 AM
#21
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
-
Oct 22nd, 2006, 10:30 AM
#22
Thread Starter
Hyperactive Member
Re: How do I pass a crystal report as argument?
Hi
They are the same reports. Only the layouts differ.
-
Oct 22nd, 2006, 10:50 AM
#23
Re: How do I pass a crystal report as argument?
 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.
-
Oct 22nd, 2006, 10:54 AM
#24
Thread Starter
Hyperactive Member
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.
-
Oct 22nd, 2006, 11:26 AM
#25
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.
-
Nov 20th, 2006, 10:33 AM
#26
Thread Starter
Hyperactive Member
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
-
Nov 21st, 2006, 01:56 AM
#27
Re: How do I pass a crystal report as argument?
Did you try as I suggest to you in my Last post??
-
Nov 21st, 2006, 04:11 AM
#28
Thread Starter
Hyperactive Member
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.
-
Nov 21st, 2006, 04:17 AM
#29
Thread Starter
Hyperactive Member
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.
-
Nov 21st, 2006, 05:14 AM
#30
Thread Starter
Hyperactive Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|