Hi,
Have been trying to rank records according highest points in a report from a crosstab query and have create the module below in vba.
Code
Option Compare Database
Dim lngLastPoints As Long
Dim lngLastRank As Long
Dim lngRankInc As Long
Function RankFunction(lngPoints As Long) As Long
If lngLastPoints = lngPoints Then
RankFunction = lngLastRank
lngRankInc = lngRankInc + 1
lngLastPoints = lngPoints
Else
lngRankInc = lngRankInc + 1
RankFunction = lngRankInc
lngLastRank = lngRankInc
lngLastPoints = lngPoints
End If
End Function
It does rank the records but the problem is that when I try to print the report if ther were 25 records the ranking begins at 26 - 50 and if I close and reopen the report it keeps on incrementing. Any suggestions?
Thanks
titanl
Have been trying to rank records according highest points in a report from a crosstab query and have create the module below in vba.
Code
Option Compare Database
Dim lngLastPoints As Long
Dim lngLastRank As Long
Dim lngRankInc As Long
Function RankFunction(lngPoints As Long) As Long
If lngLastPoints = lngPoints Then
RankFunction = lngLastRank
lngRankInc = lngRankInc + 1
lngLastPoints = lngPoints
Else
lngRankInc = lngRankInc + 1
RankFunction = lngRankInc
lngLastRank = lngRankInc
lngLastPoints = lngPoints
End If
End Function
It does rank the records but the problem is that when I try to print the report if ther were 25 records the ranking begins at 26 - 50 and if I close and reopen the report it keeps on incrementing. Any suggestions?
Thanks
titanl