saintedmunds
Technical User
Hi
I have the following function in an access project.
But it wont update does any one now why please.
Dim cmd As New adodb.Command
Dim param1 As adodb.Parameter
Dim param2 As adodb.Parameter
Dim cnn As adodb.Connection
Dim RS As adodb.Recordset
Set cnn = CurrentProject.Connection
Set RS = New adodb.Recordset
Dim intRank As String
Dim intCount As Integer
Dim intOldScore As Integer
With cmd
.ActiveConnection = cnn
With RS
.CursorType = adOpenDynamic
.LockType = adLockOptimistic
.CursorLocation = adUseServer
End With
Set param1 = .CreateParameter("@TermID", adInteger, adParamInput)
Set param2 = .CreateParameter("@FormsExamsID", adInteger, adParamInput)
.Parameters.Append param1
.Parameters.Append param2
param1.Value = fnTermID()
param2.Value = fnFormsExamsID()
.CommandType = adCmdStoredProc
.CommandText = strQueryName
Set RS = .Execute
End With
RS.Sort = strScoreFldName & " DESC"
intRank = 1
Do While Not RS.EOF
If RS.Fields(strScoreFldName) = 0 Then
Exit Do
End If
intCount = intCount + 1
If intOldScore = RS.Fields(strScoreFldName) Then
RS.MovePrevious
If Not Right(RS.Fields(strRankFldName), 1) = "=" Then
RS.Fields(strRankFldName) = RS.Fields(strRankFldName) & "="
RS.Update
End If
RS.MoveNext
End If
If Not intOldScore = RS.Fields(strScoreFldName) Then
intRank = intCount
Else
intRank = intRank & "="
End If
RS.Fields(strRankFldName) = intRank "ERROR HERE"
If Right(intRank, 1) = "=" Then
intRank = Left(intRank, Len(intRank) - 1)
End If
RS.Update
intOldScore = RS.Fields(strScoreFldName)
RS.MoveNext
Loop
RS.Close
Set RS = Nothing
Set cnn = Nothing
Me.Requery
End Function
Cheers
I have the following function in an access project.
But it wont update does any one now why please.
Dim cmd As New adodb.Command
Dim param1 As adodb.Parameter
Dim param2 As adodb.Parameter
Dim cnn As adodb.Connection
Dim RS As adodb.Recordset
Set cnn = CurrentProject.Connection
Set RS = New adodb.Recordset
Dim intRank As String
Dim intCount As Integer
Dim intOldScore As Integer
With cmd
.ActiveConnection = cnn
With RS
.CursorType = adOpenDynamic
.LockType = adLockOptimistic
.CursorLocation = adUseServer
End With
Set param1 = .CreateParameter("@TermID", adInteger, adParamInput)
Set param2 = .CreateParameter("@FormsExamsID", adInteger, adParamInput)
.Parameters.Append param1
.Parameters.Append param2
param1.Value = fnTermID()
param2.Value = fnFormsExamsID()
.CommandType = adCmdStoredProc
.CommandText = strQueryName
Set RS = .Execute
End With
RS.Sort = strScoreFldName & " DESC"
intRank = 1
Do While Not RS.EOF
If RS.Fields(strScoreFldName) = 0 Then
Exit Do
End If
intCount = intCount + 1
If intOldScore = RS.Fields(strScoreFldName) Then
RS.MovePrevious
If Not Right(RS.Fields(strRankFldName), 1) = "=" Then
RS.Fields(strRankFldName) = RS.Fields(strRankFldName) & "="
RS.Update
End If
RS.MoveNext
End If
If Not intOldScore = RS.Fields(strScoreFldName) Then
intRank = intCount
Else
intRank = intRank & "="
End If
RS.Fields(strRankFldName) = intRank "ERROR HERE"
If Right(intRank, 1) = "=" Then
intRank = Left(intRank, Len(intRank) - 1)
End If
RS.Update
intOldScore = RS.Fields(strScoreFldName)
RS.MoveNext
Loop
RS.Close
Set RS = Nothing
Set cnn = Nothing
Me.Requery
End Function
Cheers