Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Paasing Non-Aggregates to a Group

Status
Not open for further replies.

roberthagan

Technical User
May 9, 2006
27
US
I'm another frustrated Crystal user, tring to figure out things that are easy there, and not obvious in RS.
I have many situations where I need to find a value in a set of rows based on some condition and pass it for display on a group.
Example, in a set of client statuses, find the status just before a closing status. On the detail row, use the Previous function:
Iif (Fields!STATUS.value = "C", Previous(Fields!STATUS.Value),"")

In Crystal just declare a variable: lastStatusBeforeClose :="" on the group header, Put another lastStatusBeforeClose variable on the group footer to display the value. There doesn't seem to be anything comparable in RS. I've tried referencing the detail textbox from the group, but discovered that you can't reference objects between groups. I've tried doing a function and gotten an error about declaring a non shared object... etc. Is there a solution?
 
I ran across this thread:
It demonstrates a method of adding a counter variable and resetting it where needed. Exactly what I needed. But...
the reset doesn't seem to work as I expected.

Public Shared myStatus as String
Public Shared Function ClientHdr(byVal Input1 As String) As String
If (Input1 <> Nothing) Then
myStatus = Input1
Return myStatus
Else
myStatus = "Error"
Return myStatus
End If
End Function

Public Shared Function ClientFoot() As String
Return myStatus
End Function

Public Shared Function LastStatusBeforeClose(ByVal Input2 As String)
If (Input2 <> Nothing) Then
myStatus = Input2
Return myStatus
Else
myStatus= "Error"
End if
End Function
I call the detail function:
=IIF(Fields!STATUS.Value = "C", code.LastStatusBeforeClose(Previous(Fields!STATUS.Value)),"__")
If I use code.client_hdr("__") Client_foot returns that,
If I eliminate it or reset in the footer after displaying the value, footer shows the last value status from the previous group. It appears the header is in a different scope.

The counter example doesn't use a scope, and turns out to have the same problem, if trying to reset at the start of a new group:

Public Shared MyCounter As Integer
Public Shared Function cntr_head As String
MyCounter = 0
Return MyCounter.ToString
End Function
Public Shared Function cntr_detail As String
MyCounter += 1
Return MyCounter.ToString
End Function

Public Shared Function cntr_foot As String
Return MyCounter.ToString
End Function


The detail produces a running total.
If the cntr_head function is present, the footer is always 0
If it is not, the footer displays the last detail value of the PREVIOUS group:

gphead 1
detail 1
detail 2
---------------
gpfoot 0

gphead 2
detail 3
detail 4
---------------
gpfoot 2

gphead 3
detail 5
detail 6
---------------
gpfoot 4

Is there a fix for this?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top