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!

Sort Data Row Variable

Status
Not open for further replies.

coolbabe2007

Programmer
Apr 19, 2007
5
GB
Hi,


I am writing a new report. In this report I have a field which is calculated based on certain dates and difference between them. I have handled this by writing a samll piece of code in OnRead(), by declaring the variable as datarow variable and used it in report. Now I have another challenge of sorting this in asc order. Since this being a datarow variable, I cannot use it in my query to sort. So I thought I could do it by using
comparerow() in memory data sorter. Now my problem is, It is always using only the last value of the datarow for comaprison and the other values are getting omiited. Say suppose, though thevalues are 10, 20, 30, 40. Only 40 is getting considered and rest is omiited and only 40 is getting dispalyed in my report.
Below is the code I have written in Onread and Compare
methods:-

-----On Read()----------------------------------------
Sub OnRead( )
Super::OnRead( )
NikuSequential::DataFound = True

Static ResourceID as String
Static ContractEndDate as Date
Dim msg, Message as string

If ResourceID = RESID Then

PreviousEndDate = ContractEndDate
ContractEndDate = CURRENDDATE
If DATEDIFF("d", PreviousEndDate,CURRSTARTDATE) <= 180 Then
TotalDays = TotalDays +
DATEDIFF("d",CURRSTARTDATE,CURRENDDATE)
Else
TotalDays = DATEDIFF("d",CURRSTARTDATE,CURRENDDATE)
End If
Else
ResourceID = RESID
ContractEndDate = CURRENDDATE
TotalDays = DATEDIFF("d",CURRSTARTDATE,CURRENDDATE)
PreviousEndDate = NULL
End If
msg = "Resource ID " & ResourceID
msgbox msg
Message = "Total Days " & TotalDays
msgbox Message

End Sub


--------------------------Comapre()------------------------------
------------------
Function Compare( row1 As AcDataRow, row2 As AcDataRow ) As Integer

Dim k1 As Variant
Dim k2 As Variant
Dim msg, Message As String

' get the values to be compared. sApp::sKey holds the sort key field
' name in the datarow
k1 = row1.GetValue(Contractorswithin60days::sKey1)
k2 = row2.GetValue(Contractorswithin60days::sKey1)
Compare = CompareKeys(k1, k2)
If Compare <> 0 Then
Exit Function
End If


End Function


Please let me know how to do this comparison from datarow variable .

Thanks in Advance.
 
Can any one please help me out on this. Needs to be moved to production by today. Its very urgent. Please help me out.
 
Did you solve this?
I would never touch compare().
I'd store all the results into a table, then use a seql section with a 2nd report to read the table and use a group section to do the sorting for you.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top