A
Al Campagna
**Posted this about 2 hours ago, and it still hasn't shown up. Pardon if a duplicate...
I'm parsing down through many records using DAO loop , examining values as I go.
If a certain condition is met, I need to Update one or more records that were previously
accessed via the loop, and set those values to 0.
Thought I could insert an Update query to accomplish that, and then continue on to the
next DAO record.
Dim rst As DAO.Recordset
Set rst = Form.RecordsetClone
PreviousLocationScore = DSum("[RawScore]", "qryDefectsGraphedScoring",
"GraphedID < " & rst("GraphedID") & " And DefectLocation = " & rst("DefectLocation"))
' *** PreviousLocationScore returns correct result
If rst("DefectLength") >= 1000 Then
rst.Edit
rst("FinalScore") = rst("RawScore")
rst("ScoreCode") = " D/LS " & rst("DefectLocation") & " = " & LastLocation
rst.Update
' *** Update those previous records (RollNo text, DefectLocation integer, GraphedID long)
DoCmd.RunSQL "UPDATE tblDefectsGraphed SET tblDefectsGraphed.FinalScore = 0 " & _
"WHERE (((tblDefectsGraphed.RollNo) = rst('RollNo') AND
((tblDefectsGraphed.DefectLocation) = rst('DefectLocation') AND
((tblDefectsGraphed.GraphedID) < rst('[GraphedID]')));"
GoTo DoneScoring
End If
The RunSQL code does not work. No Errors, no Update warning mesage.
Perhaps the DAO needs to be closed and re-opened?
Perhaps the query can not "see" the rst values?
Could I accomplish the Update using DAO?
Any help appreciated... couldn't figure out what to search the Access groups with
to find an answer.
Thanks,
Al Campagna
I'm parsing down through many records using DAO loop , examining values as I go.
If a certain condition is met, I need to Update one or more records that were previously
accessed via the loop, and set those values to 0.
Thought I could insert an Update query to accomplish that, and then continue on to the
next DAO record.
Dim rst As DAO.Recordset
Set rst = Form.RecordsetClone
PreviousLocationScore = DSum("[RawScore]", "qryDefectsGraphedScoring",
"GraphedID < " & rst("GraphedID") & " And DefectLocation = " & rst("DefectLocation"))
' *** PreviousLocationScore returns correct result
If rst("DefectLength") >= 1000 Then
rst.Edit
rst("FinalScore") = rst("RawScore")
rst("ScoreCode") = " D/LS " & rst("DefectLocation") & " = " & LastLocation
rst.Update
' *** Update those previous records (RollNo text, DefectLocation integer, GraphedID long)
DoCmd.RunSQL "UPDATE tblDefectsGraphed SET tblDefectsGraphed.FinalScore = 0 " & _
"WHERE (((tblDefectsGraphed.RollNo) = rst('RollNo') AND
((tblDefectsGraphed.DefectLocation) = rst('DefectLocation') AND
((tblDefectsGraphed.GraphedID) < rst('[GraphedID]')));"
GoTo DoneScoring
End If
The RunSQL code does not work. No Errors, no Update warning mesage.
Perhaps the DAO needs to be closed and re-opened?
Perhaps the query can not "see" the rst values?
Could I accomplish the Update using DAO?
Any help appreciated... couldn't figure out what to search the Access groups with
to find an answer.
Thanks,
Al Campagna