Friday, February 24, 2012

Custom Code - Global Variable

I try to create a global variable in Custom Code. Then I increment the variable by 1 in detail section. Then I want to get this variable in footer section. The value is set to zero. Then I create this variable: Class Name = System.Int64 and Instance Name = iIBDry20 in Report References. In the custom section, I write the following code:
Public Sub ResetVariable ()
iIBDry20 = 0
End Sub
Public Function SumIBDry20(ByVal EqpLength As Integer, ByVal EqpType As String, ByVal EqpStatus As String)
iIBDry20 = IIf(EqpLength = 20 And EqpType = "NORMAL" And EqpStatus= "Inbound", iIBDry20 + 1, iIBDry20)
Return iIBDry20
End Function
Public Function GetIBDry20() As Integer
Return iIBDry20
End Function
Then an error - There is an error on line 2 of custm code: [BC30526] property 'iIBDry 20' is 'ReadOnly'
Can anyone help me !!!Instance variables used to instantiate classes are read only. Instead of
doing that, you would need to declare the variable in your code:
Dim iIBDry20 as integer
However: Evaluation order of expressions within the report is officially
undefined, so you cannot depend on this approach to populate a value for use
in your footer. It may happen to work in certain cases, but it will not
work in all cases and is not guaranteed to work in the future.
A better approach would be to put the following expression in your footer:
=Sum(IIf(Fields!EqpLength.Value = 20 And Fields!EqpType.Value = "NORMAL" And
Fields!EqpStatus.Value = "Inbound", 1, 0))
--
My employer's lawyers require me to say:
"This posting is provided 'AS IS' with no warranties, and confers no
rights."
"May Liu" <MayLiu@.discussions.microsoft.com> wrote in message
news:5945485A-299C-4B55-AAC4-B0535CA7747B@.microsoft.com...
> I try to create a global variable in Custom Code. Then I increment the
variable by 1 in detail section. Then I want to get this variable in footer
section. The value is set to zero. Then I create this variable: Class Name
= System.Int64 and Instance Name = iIBDry20 in Report References. In the
custom section, I write the following code:
> Public Sub ResetVariable ()
> iIBDry20 = 0
> End Sub
> Public Function SumIBDry20(ByVal EqpLength As Integer, ByVal EqpType As
String, ByVal EqpStatus As String)
> iIBDry20 = IIf(EqpLength = 20 And EqpType = "NORMAL" And
EqpStatus= "Inbound", iIBDry20 + 1, iIBDry20)
> Return iIBDry20
> End Function
> Public Function GetIBDry20() As Integer
> Return iIBDry20
> End Function
> Then an error - There is an error on line 2 of custm code: [BC30526]
property 'iIBDry 20' is 'ReadOnly'
> Can anyone help me !!!
>|||Thanks a lot !!! This problem annoy me so long time.
Does it means that I can't create global variable for stroing some values and then retrieved this value in different report sections ?
"Chris Hays [MSFT]" wrote:
> Instance variables used to instantiate classes are read only. Instead of
> doing that, you would need to declare the variable in your code:
> Dim iIBDry20 as integer
>
> However: Evaluation order of expressions within the report is officially
> undefined, so you cannot depend on this approach to populate a value for use
> in your footer. It may happen to work in certain cases, but it will not
> work in all cases and is not guaranteed to work in the future.
> A better approach would be to put the following expression in your footer:
> =Sum(IIf(Fields!EqpLength.Value = 20 And Fields!EqpType.Value = "NORMAL" And
> Fields!EqpStatus.Value = "Inbound", 1, 0))
> --
> My employer's lawyers require me to say:
> "This posting is provided 'AS IS' with no warranties, and confers no
> rights."
> "May Liu" <MayLiu@.discussions.microsoft.com> wrote in message
> news:5945485A-299C-4B55-AAC4-B0535CA7747B@.microsoft.com...
> > I try to create a global variable in Custom Code. Then I increment the
> variable by 1 in detail section. Then I want to get this variable in footer
> section. The value is set to zero. Then I create this variable: Class Name
> = System.Int64 and Instance Name = iIBDry20 in Report References. In the
> custom section, I write the following code:
> >
> > Public Sub ResetVariable ()
> > iIBDry20 = 0
> > End Sub
> >
> > Public Function SumIBDry20(ByVal EqpLength As Integer, ByVal EqpType As
> String, ByVal EqpStatus As String)
> > iIBDry20 = IIf(EqpLength = 20 And EqpType = "NORMAL" And
> EqpStatus= "Inbound", iIBDry20 + 1, iIBDry20)
> > Return iIBDry20
> > End Function
> >
> > Public Function GetIBDry20() As Integer
> > Return iIBDry20
> > End Function
> >
> > Then an error - There is an error on line 2 of custm code: [BC30526]
> property 'iIBDry 20' is 'ReadOnly'
> >
> > Can anyone help me !!!
> >
>
>|||I see issues like this crop up every now and then, so I'd love to get
defined execution order (and even better, controllable execution order) into
the feature list. But it's competing with a huge list of other features
ranging from great-to-have to can't-ship-without. The likelihood of fitting
this into the next version is, unfortunately, rather low.
It will stay on our wishlist, haunting me, until we have time to implement
it.
--
My employer's lawyers require me to say:
"This posting is provided 'AS IS' with no warranties, and confers no
rights."
"Chris McGuigan" <ChrisMcGuigan@.discussions.microsoft.com> wrote in message
news:2059D003-100C-430F-820E-ADE33069497E@.microsoft.com...
> Good question May Liu.
> Chris you've stated this before to me as well. What you are effectively
saying is 'don't use global/public variables'!
> Not knowing or being able to control the order items are processed in is
seriously limiting - especially if they're likely to be reset.
> Crystal does have a method of control - I can't remember the exact syntax
(that's a good sign - CR is fading from memory!) but before a formula, you
state which pass it's to be calculated on i.e. WhileReadingRecords,
WhilePrintingRecords or the EvaluateAfter() function.
> I feel MS needs to address this area as a priority in the next SP/Release.
At the very least, the state of Public variables needs to be maintained
throughout the life of the report execution.
> I have had to give up on generating an automatic table of contents with
page numbers for a large report which calls 18 sub reports. This will now be
done BY HAND in Excel. I could have done it in Crystal (but I won't for
political, economic and pig-headed reasons!).
> Regards
> Chris McGuigan
> "May Liu" wrote:
> > Thanks a lot !!! This problem annoy me so long time.
> >
> > Does it means that I can't create global variable for stroing some
values and then retrieved this value in different report sections ?
> >
> > "Chris Hays [MSFT]" wrote:
> >
> > > Instance variables used to instantiate classes are read only. Instead
of
> > > doing that, you would need to declare the variable in your code:
> > >
> > > Dim iIBDry20 as integer
> > >
> > >
> > > However: Evaluation order of expressions within the report is
officially
> > > undefined, so you cannot depend on this approach to populate a value
for use
> > > in your footer. It may happen to work in certain cases, but it will
not
> > > work in all cases and is not guaranteed to work in the future.
> > >
> > > A better approach would be to put the following expression in your
footer:
> > >
> > > =Sum(IIf(Fields!EqpLength.Value = 20 And Fields!EqpType.Value ="NORMAL" And
> > > Fields!EqpStatus.Value = "Inbound", 1, 0))
> > >
> > > --
> > > My employer's lawyers require me to say:
> > > "This posting is provided 'AS IS' with no warranties, and confers no
> > > rights."
> > >
> > > "May Liu" <MayLiu@.discussions.microsoft.com> wrote in message
> > > news:5945485A-299C-4B55-AAC4-B0535CA7747B@.microsoft.com...
> > > > I try to create a global variable in Custom Code. Then I increment
the
> > > variable by 1 in detail section. Then I want to get this variable in
footer
> > > section. The value is set to zero. Then I create this variable:
Class Name
> > > = System.Int64 and Instance Name = iIBDry20 in Report References. In
the
> > > custom section, I write the following code:
> > > >
> > > > Public Sub ResetVariable ()
> > > > iIBDry20 = 0
> > > > End Sub
> > > >
> > > > Public Function SumIBDry20(ByVal EqpLength As Integer, ByVal EqpType
As
> > > String, ByVal EqpStatus As String)
> > > > iIBDry20 = IIf(EqpLength = 20 And EqpType = "NORMAL" And
> > > EqpStatus= "Inbound", iIBDry20 + 1, iIBDry20)
> > > > Return iIBDry20
> > > > End Function
> > > >
> > > > Public Function GetIBDry20() As Integer
> > > > Return iIBDry20
> > > > End Function
> > > >
> > > > Then an error - There is an error on line 2 of custm code: [BC30526]
> > > property 'iIBDry 20' is 'ReadOnly'
> > > >
> > > > Can anyone help me !!!
> > > >
> > >
> > >
> > >|||Hi Chris,
Thanks for the response.
I appreciate your comments. It's a shame because it is a limiting factor in terms of making good reports into great reports (and Crystal can do it - did I mention that already! ;-) ).
I'll mention my scenario in case you have an idea on how to get around it.
My company produces a set of 'Management Accounts' once a month. This currently comprises 22 different reports. I am converting all 22 to RS. I created a Control Report which puts these together in one easy to run package. It runs each of the other reports as a subreport. So far so good.
Page one is a table of contents with page numbers. So before each sub-report I had a textbox which called a function in custom code which set a public variable to hold the page number. I set the table of contents to print at the end so the variables would be populated. But, as you've predicted before, they have all been reset to zero.
Any ideas?
Regards
Chris McGuigan
"Chris Hays [MSFT]" wrote:
> I see issues like this crop up every now and then, so I'd love to get
> defined execution order (and even better, controllable execution order) into
> the feature list. But it's competing with a huge list of other features
> ranging from great-to-have to can't-ship-without. The likelihood of fitting
> this into the next version is, unfortunately, rather low.
> It will stay on our wishlist, haunting me, until we have time to implement
> it.
> --
> My employer's lawyers require me to say:
> "This posting is provided 'AS IS' with no warranties, and confers no
> rights."
> "Chris McGuigan" <ChrisMcGuigan@.discussions.microsoft.com> wrote in message
> news:2059D003-100C-430F-820E-ADE33069497E@.microsoft.com...
> > Good question May Liu.
> > Chris you've stated this before to me as well. What you are effectively
> saying is 'don't use global/public variables'!
> > Not knowing or being able to control the order items are processed in is
> seriously limiting - especially if they're likely to be reset.
> >
> > Crystal does have a method of control - I can't remember the exact syntax
> (that's a good sign - CR is fading from memory!) but before a formula, you
> state which pass it's to be calculated on i.e. WhileReadingRecords,
> WhilePrintingRecords or the EvaluateAfter() function.
> >
> > I feel MS needs to address this area as a priority in the next SP/Release.
> At the very least, the state of Public variables needs to be maintained
> throughout the life of the report execution.
> >
> > I have had to give up on generating an automatic table of contents with
> page numbers for a large report which calls 18 sub reports. This will now be
> done BY HAND in Excel. I could have done it in Crystal (but I won't for
> political, economic and pig-headed reasons!).
> >
> > Regards
> > Chris McGuigan
> >
> > "May Liu" wrote:
> >
> > > Thanks a lot !!! This problem annoy me so long time.
> > >
> > > Does it means that I can't create global variable for stroing some
> values and then retrieved this value in different report sections ?
> > >
> > > "Chris Hays [MSFT]" wrote:
> > >
> > > > Instance variables used to instantiate classes are read only. Instead
> of
> > > > doing that, you would need to declare the variable in your code:
> > > >
> > > > Dim iIBDry20 as integer
> > > >
> > > >
> > > > However: Evaluation order of expressions within the report is
> officially
> > > > undefined, so you cannot depend on this approach to populate a value
> for use
> > > > in your footer. It may happen to work in certain cases, but it will
> not
> > > > work in all cases and is not guaranteed to work in the future.
> > > >
> > > > A better approach would be to put the following expression in your
> footer:
> > > >
> > > > =Sum(IIf(Fields!EqpLength.Value = 20 And Fields!EqpType.Value => "NORMAL" And
> > > > Fields!EqpStatus.Value = "Inbound", 1, 0))
> > > >
> > > > --
> > > > My employer's lawyers require me to say:
> > > > "This posting is provided 'AS IS' with no warranties, and confers no
> > > > rights."
> > > >
> > > > "May Liu" <MayLiu@.discussions.microsoft.com> wrote in message
> > > > news:5945485A-299C-4B55-AAC4-B0535CA7747B@.microsoft.com...
> > > > > I try to create a global variable in Custom Code. Then I increment
> the
> > > > variable by 1 in detail section. Then I want to get this variable in
> footer
> > > > section. The value is set to zero. Then I create this variable:
> Class Name
> > > > = System.Int64 and Instance Name = iIBDry20 in Report References. In
> the
> > > > custom section, I write the following code:
> > > > >
> > > > > Public Sub ResetVariable ()
> > > > > iIBDry20 = 0
> > > > > End Sub
> > > > >
> > > > > Public Function SumIBDry20(ByVal EqpLength As Integer, ByVal EqpType
> As
> > > > String, ByVal EqpStatus As String)
> > > > > iIBDry20 = IIf(EqpLength = 20 And EqpType = "NORMAL" And
> > > > EqpStatus= "Inbound", iIBDry20 + 1, iIBDry20)
> > > > > Return iIBDry20
> > > > > End Function
> > > > >
> > > > > Public Function GetIBDry20() As Integer
> > > > > Return iIBDry20
> > > > > End Function
> > > > >
> > > > > Then an error - There is an error on line 2 of custm code: [BC30526]
> > > > property 'iIBDry 20' is 'ReadOnly'
> > > > >
> > > > > Can anyone help me !!!
> > > > >
> > > >
> > > >
> > > >
>
>|||Unfortunately, there's currently no good way to build a table of contents.
And even adding defined execution order isn't going to help, since
pagination happens as a completely separate step from the rest of the
report. This is because you can request the same report with different page
size/margin settings (and even an entirely different rendering target, which
could radically change pagination). Under normal circumstances, we don't
want to force reexecution of the entire report just because you change your
margins.
To handle table of contents type operations, we're going to (eventually)
have to implement an entirely new mode wherein we know that the body of the
report contains references to page numbers, which will force the entire
report to reexecute if pagination information changes.
In the mean time, there's no general solution for the table of contents
problem.
But... Since you're doing this in a batch once a month, you may not need a
fully general solution.
Without further ado, here's Sleazy Hack #792 ("Simulating Table of Contents
in Batch Reporting Scenarios"):
1. Write a custom assembly containing a class that can write rows to a
TableOfContents table in your database.
Have shared methods for both initializing the TOC and writing a new row
to the TOC.
Note: Don't forget to give it database permissions in the CAS file when
you deploy it to your server.
See the documentation for details on custom assemblies.
2. In the Code section of the report, call the TOC initialization in the
OnInit() event.
3. At the start of each section you want to appear in your TOC, put a
hidden textbox that contains the label you want to appear in your TOC.
4. In the page header, put a hidden textbox with something like the
following expression:
=Code.MyTOCClass.AddToTOC(Globals.PageNumber,ReportItems!Textbox1.Value
& ReportItems!Textbox2.Value & ReportItems!Textbox3.Value)
Texbox1, Textbox2 and Textbox3 are the names of the hidden textboxes
from step 3 (since only one will appear on any given page, the rest will be
empty)
5. Add a dataset to your report which selects from the TableOfContents
table
6. Display the results of the TOC data set in a table at the end of your
report*
7. Run the report twice. The first time will initialize the TOC. The
second time will use the values from the previous run.
* If you want it at the beginning, you'll either need to run the report
three times (the first to get some rows into the TOC table, the second to
get the numbers populated correctly and the third to use those numbers) or
you'll need to make sure the TOC table has the right number of rows to begin
with (perhaps by not emptying it from the previous month) otherwise your
page numbers will be incorrect due to the TOC pushing things around. This
isn't an issue if your TOC is only one page long and has PageBreakAtEnd,
however.
--
My employer's lawyers require me to say:
"This posting is provided 'AS IS' with no warranties, and confers no
rights."
"Chris McGuigan" <ChrisMcGuigan@.discussions.microsoft.com> wrote in message
news:049E2108-6416-4607-9F43-6046AD81087F@.microsoft.com...
> Hi Chris,
> Thanks for the response.
> I appreciate your comments. It's a shame because it is a limiting factor
in terms of making good reports into great reports (and Crystal can do it -
did I mention that already! ;-) ).
> I'll mention my scenario in case you have an idea on how to get around it.
> My company produces a set of 'Management Accounts' once a month. This
currently comprises 22 different reports. I am converting all 22 to RS. I
created a Control Report which puts these together in one easy to run
package. It runs each of the other reports as a subreport. So far so good.
> Page one is a table of contents with page numbers. So before each
sub-report I had a textbox which called a function in custom code which set
a public variable to hold the page number. I set the table of contents to
print at the end so the variables would be populated. But, as you've
predicted before, they have all been reset to zero.
> Any ideas?
> Regards
> Chris McGuigan
> "Chris Hays [MSFT]" wrote:
> > I see issues like this crop up every now and then, so I'd love to get
> > defined execution order (and even better, controllable execution order)
into
> > the feature list. But it's competing with a huge list of other features
> > ranging from great-to-have to can't-ship-without. The likelihood of
fitting
> > this into the next version is, unfortunately, rather low.
> > It will stay on our wishlist, haunting me, until we have time to
implement
> > it.
> >
> > --
> > My employer's lawyers require me to say:
> > "This posting is provided 'AS IS' with no warranties, and confers no
> > rights."
> >
> > "Chris McGuigan" <ChrisMcGuigan@.discussions.microsoft.com> wrote in
message
> > news:2059D003-100C-430F-820E-ADE33069497E@.microsoft.com...
> > > Good question May Liu.
> > > Chris you've stated this before to me as well. What you are
effectively
> > saying is 'don't use global/public variables'!
> > > Not knowing or being able to control the order items are processed in
is
> > seriously limiting - especially if they're likely to be reset.
> > >
> > > Crystal does have a method of control - I can't remember the exact
syntax
> > (that's a good sign - CR is fading from memory!) but before a formula,
you
> > state which pass it's to be calculated on i.e. WhileReadingRecords,
> > WhilePrintingRecords or the EvaluateAfter() function.
> > >
> > > I feel MS needs to address this area as a priority in the next
SP/Release.
> > At the very least, the state of Public variables needs to be maintained
> > throughout the life of the report execution.
> > >
> > > I have had to give up on generating an automatic table of contents
with
> > page numbers for a large report which calls 18 sub reports. This will
now be
> > done BY HAND in Excel. I could have done it in Crystal (but I won't for
> > political, economic and pig-headed reasons!).
> > >
> > > Regards
> > > Chris McGuigan
> > >
> > > "May Liu" wrote:
> > >
> > > > Thanks a lot !!! This problem annoy me so long time.
> > > >
> > > > Does it means that I can't create global variable for stroing some
> > values and then retrieved this value in different report sections ?
> > > >
> > > > "Chris Hays [MSFT]" wrote:
> > > >
> > > > > Instance variables used to instantiate classes are read only.
Instead
> > of
> > > > > doing that, you would need to declare the variable in your code:
> > > > >
> > > > > Dim iIBDry20 as integer
> > > > >
> > > > >
> > > > > However: Evaluation order of expressions within the report is
> > officially
> > > > > undefined, so you cannot depend on this approach to populate a
value
> > for use
> > > > > in your footer. It may happen to work in certain cases, but it
will
> > not
> > > > > work in all cases and is not guaranteed to work in the future.
> > > > >
> > > > > A better approach would be to put the following expression in your
> > footer:
> > > > >
> > > > > =Sum(IIf(Fields!EqpLength.Value = 20 And Fields!EqpType.Value => > "NORMAL" And
> > > > > Fields!EqpStatus.Value = "Inbound", 1, 0))
> > > > >
> > > > > --
> > > > > My employer's lawyers require me to say:
> > > > > "This posting is provided 'AS IS' with no warranties, and confers
no
> > > > > rights."
> > > > >
> > > > > "May Liu" <MayLiu@.discussions.microsoft.com> wrote in message
> > > > > news:5945485A-299C-4B55-AAC4-B0535CA7747B@.microsoft.com...
> > > > > > I try to create a global variable in Custom Code. Then I
increment
> > the
> > > > > variable by 1 in detail section. Then I want to get this variable
in
> > footer
> > > > > section. The value is set to zero. Then I create this variable:
> > Class Name
> > > > > = System.Int64 and Instance Name = iIBDry20 in Report References.
In
> > the
> > > > > custom section, I write the following code:
> > > > > >
> > > > > > Public Sub ResetVariable ()
> > > > > > iIBDry20 = 0
> > > > > > End Sub
> > > > > >
> > > > > > Public Function SumIBDry20(ByVal EqpLength As Integer, ByVal
EqpType
> > As
> > > > > String, ByVal EqpStatus As String)
> > > > > > iIBDry20 = IIf(EqpLength = 20 And EqpType = "NORMAL"
And
> > > > > EqpStatus= "Inbound", iIBDry20 + 1, iIBDry20)
> > > > > > Return iIBDry20
> > > > > > End Function
> > > > > >
> > > > > > Public Function GetIBDry20() As Integer
> > > > > > Return iIBDry20
> > > > > > End Function
> > > > > >
> > > > > > Then an error - There is an error on line 2 of custm code:
[BC30526]
> > > > > property 'iIBDry 20' is 'ReadOnly'
> > > > > >
> > > > > > Can anyone help me !!!
> > > > > >
> > > > >
> > > > >
> > > > >
> >
> >
> >|||Thanks Chris.
I'll try this when I've sussed out how to do custom assemblies!
Regards
Chris
"Chris Hays [MSFT]" wrote:
> Unfortunately, there's currently no good way to build a table of contents.
> And even adding defined execution order isn't going to help, since
> pagination happens as a completely separate step from the rest of the
> report. This is because you can request the same report with different page
> size/margin settings (and even an entirely different rendering target, which
> could radically change pagination). Under normal circumstances, we don't
> want to force reexecution of the entire report just because you change your
> margins.
> To handle table of contents type operations, we're going to (eventually)
> have to implement an entirely new mode wherein we know that the body of the
> report contains references to page numbers, which will force the entire
> report to reexecute if pagination information changes.
> In the mean time, there's no general solution for the table of contents
> problem.
> But... Since you're doing this in a batch once a month, you may not need a
> fully general solution.
> Without further ado, here's Sleazy Hack #792 ("Simulating Table of Contents
> in Batch Reporting Scenarios"):
> 1. Write a custom assembly containing a class that can write rows to a
> TableOfContents table in your database.
> Have shared methods for both initializing the TOC and writing a new row
> to the TOC.
> Note: Don't forget to give it database permissions in the CAS file when
> you deploy it to your server.
> See the documentation for details on custom assemblies.
> 2. In the Code section of the report, call the TOC initialization in the
> OnInit() event.
> 3. At the start of each section you want to appear in your TOC, put a
> hidden textbox that contains the label you want to appear in your TOC.
> 4. In the page header, put a hidden textbox with something like the
> following expression:
> =Code.MyTOCClass.AddToTOC(Globals.PageNumber,ReportItems!Textbox1.Value
> & ReportItems!Textbox2.Value & ReportItems!Textbox3.Value)
> Texbox1, Textbox2 and Textbox3 are the names of the hidden textboxes
> from step 3 (since only one will appear on any given page, the rest will be
> empty)
> 5. Add a dataset to your report which selects from the TableOfContents
> table
> 6. Display the results of the TOC data set in a table at the end of your
> report*
> 7. Run the report twice. The first time will initialize the TOC. The
> second time will use the values from the previous run.
> * If you want it at the beginning, you'll either need to run the report
> three times (the first to get some rows into the TOC table, the second to
> get the numbers populated correctly and the third to use those numbers) or
> you'll need to make sure the TOC table has the right number of rows to begin
> with (perhaps by not emptying it from the previous month) otherwise your
> page numbers will be incorrect due to the TOC pushing things around. This
> isn't an issue if your TOC is only one page long and has PageBreakAtEnd,
> however.
> --
> My employer's lawyers require me to say:
> "This posting is provided 'AS IS' with no warranties, and confers no
> rights."
> "Chris McGuigan" <ChrisMcGuigan@.discussions.microsoft.com> wrote in message
> news:049E2108-6416-4607-9F43-6046AD81087F@.microsoft.com...
> > Hi Chris,
> > Thanks for the response.
> > I appreciate your comments. It's a shame because it is a limiting factor
> in terms of making good reports into great reports (and Crystal can do it -
> did I mention that already! ;-) ).
> >
> > I'll mention my scenario in case you have an idea on how to get around it.
> > My company produces a set of 'Management Accounts' once a month. This
> currently comprises 22 different reports. I am converting all 22 to RS. I
> created a Control Report which puts these together in one easy to run
> package. It runs each of the other reports as a subreport. So far so good.
> >
> > Page one is a table of contents with page numbers. So before each
> sub-report I had a textbox which called a function in custom code which set
> a public variable to hold the page number. I set the table of contents to
> print at the end so the variables would be populated. But, as you've
> predicted before, they have all been reset to zero.
> > Any ideas?
> >
> > Regards
> > Chris McGuigan
> >
> > "Chris Hays [MSFT]" wrote:
> >
> > > I see issues like this crop up every now and then, so I'd love to get
> > > defined execution order (and even better, controllable execution order)
> into
> > > the feature list. But it's competing with a huge list of other features
> > > ranging from great-to-have to can't-ship-without. The likelihood of
> fitting
> > > this into the next version is, unfortunately, rather low.
> > > It will stay on our wishlist, haunting me, until we have time to
> implement
> > > it.
> > >
> > > --
> > > My employer's lawyers require me to say:
> > > "This posting is provided 'AS IS' with no warranties, and confers no
> > > rights."
> > >
> > > "Chris McGuigan" <ChrisMcGuigan@.discussions.microsoft.com> wrote in
> message
> > > news:2059D003-100C-430F-820E-ADE33069497E@.microsoft.com...
> > > > Good question May Liu.
> > > > Chris you've stated this before to me as well. What you are
> effectively
> > > saying is 'don't use global/public variables'!
> > > > Not knowing or being able to control the order items are processed in
> is
> > > seriously limiting - especially if they're likely to be reset.
> > > >
> > > > Crystal does have a method of control - I can't remember the exact
> syntax
> > > (that's a good sign - CR is fading from memory!) but before a formula,
> you
> > > state which pass it's to be calculated on i.e. WhileReadingRecords,
> > > WhilePrintingRecords or the EvaluateAfter() function.
> > > >
> > > > I feel MS needs to address this area as a priority in the next
> SP/Release.
> > > At the very least, the state of Public variables needs to be maintained
> > > throughout the life of the report execution.
> > > >
> > > > I have had to give up on generating an automatic table of contents
> with
> > > page numbers for a large report which calls 18 sub reports. This will
> now be
> > > done BY HAND in Excel. I could have done it in Crystal (but I won't for
> > > political, economic and pig-headed reasons!).
> > > >
> > > > Regards
> > > > Chris McGuigan
> > > >
> > > > "May Liu" wrote:
> > > >
> > > > > Thanks a lot !!! This problem annoy me so long time.
> > > > >
> > > > > Does it means that I can't create global variable for stroing some
> > > values and then retrieved this value in different report sections ?
> > > > >
> > > > > "Chris Hays [MSFT]" wrote:
> > > > >
> > > > > > Instance variables used to instantiate classes are read only.
> Instead
> > > of
> > > > > > doing that, you would need to declare the variable in your code:
> > > > > >
> > > > > > Dim iIBDry20 as integer
> > > > > >
> > > > > >
> > > > > > However: Evaluation order of expressions within the report is
> > > officially
> > > > > > undefined, so you cannot depend on this approach to populate a
> value
> > > for use
> > > > > > in your footer. It may happen to work in certain cases, but it
> will
> > > not
> > > > > > work in all cases and is not guaranteed to work in the future.
> > > > > >
> > > > > > A better approach would be to put the following expression in your
> > > footer:
> > > > > >
> > > > > > =Sum(IIf(Fields!EqpLength.Value = 20 And Fields!EqpType.Value => > > "NORMAL" And
> > > > > > Fields!EqpStatus.Value = "Inbound", 1, 0))
> > > > > >
> > > > > > --
> > > > > > My employer's lawyers require me to say:
> > > > > > "This posting is provided 'AS IS' with no warranties, and confers
> no
> > > > > > rights."
> > > > > >
> > > > > > "May Liu" <MayLiu@.discussions.microsoft.com> wrote in message
> > > > > > news:5945485A-299C-4B55-AAC4-B0535CA7747B@.microsoft.com...
> > > > > > > I try to create a global variable in Custom Code. Then I
> increment
> > > the
> > > > > > variable by 1 in detail section. Then I want to get this variable
> in
> > > footer
> > > > > > section. The value is set to zero. Then I create this variable:
> > > Class Name
> > > > > > = System.Int64 and Instance Name = iIBDry20 in Report References.
> In
> > > the
> > > > > > custom section, I write the following code:
> > > > > > >
> > > > > > > Public Sub ResetVariable ()
> > > > > > > iIBDry20 = 0
> > > > > > > End Sub
> > > > > > >
> > > > > > > Public Function SumIBDry20(ByVal EqpLength As Integer, ByVal
> EqpType
> > > As
> > > > > > String, ByVal EqpStatus As String)
> > > > > > > iIBDry20 = IIf(EqpLength = 20 And EqpType = "NORMAL"
> And
> > > > > > EqpStatus= "Inbound", iIBDry20 + 1, iIBDry20)
> > > > > > > Return iIBDry20
> > > > > > > End Function
> > > > > > >
> > > > > > > Public Function GetIBDry20() As Integer
> > > > > > > Return iIBDry20
> > > > > > > End Function
> > > > > > >
> > > > > > > Then an error - There is an error on line 2 of custm code:
> [BC30526]
> > > > > > property 'iIBDry 20' is 'ReadOnly'
> > > > > > >
> > > > > > > Can anyone help me !!!
> > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > >
> > >
> > >
>
>

No comments:

Post a Comment