M
mscertified
Can I do the following or will it cause a problem?
I need to open a recordset on a table, then within the processing loop issue
UPDATE statements to the same table, e.g.
strSQL = "SELECT ID, ArtNumb, EffTarg, EffAct, GRRCHDate" & _
" FROM tblRpt5YrReviewProgress WHERE" & _
" (EffAct IS NOT NULL OR EffTarg IS NOT NULL)" & _
" ORDER BY ID"
rs1.Open strSQL, CurrentProject.Connection, adOpenDynamic, adLockOptimistic
strLastArt = vbNullString
While Not rs1.EOF
strArt = rs1.Fields("ArtNumb").Value
If strArt <> strLastArt Then
If strLastArt <> vbNullString Then
strSQL = "UPDATE tblRpt5YrReviewProgress SET GRRCHDAte = #" & _
dteGRRCH & "# WHERE ID = " & lngID
CurrentProject.Connection.Execute
End If
strLastArt = strArt
lngID = rs1.Fields("ID").Value
dteGRRCH = "1/1/1900"
End If
dteTarg = NZ(rs.Fields("EffTarg").Value, 0)
dteAct = NZ(rs.Fields("EffAct").Value, 0)
If dteAct > dteGRRCH Then
dteGRRCH = dteAct
End If
If dteTarg > dteGRRCH Then
dteGRRCH = dteTarg
End If
rs1.MoveNext
Wend
rs1.Close
I need to open a recordset on a table, then within the processing loop issue
UPDATE statements to the same table, e.g.
strSQL = "SELECT ID, ArtNumb, EffTarg, EffAct, GRRCHDate" & _
" FROM tblRpt5YrReviewProgress WHERE" & _
" (EffAct IS NOT NULL OR EffTarg IS NOT NULL)" & _
" ORDER BY ID"
rs1.Open strSQL, CurrentProject.Connection, adOpenDynamic, adLockOptimistic
strLastArt = vbNullString
While Not rs1.EOF
strArt = rs1.Fields("ArtNumb").Value
If strArt <> strLastArt Then
If strLastArt <> vbNullString Then
strSQL = "UPDATE tblRpt5YrReviewProgress SET GRRCHDAte = #" & _
dteGRRCH & "# WHERE ID = " & lngID
CurrentProject.Connection.Execute
End If
strLastArt = strArt
lngID = rs1.Fields("ID").Value
dteGRRCH = "1/1/1900"
End If
dteTarg = NZ(rs.Fields("EffTarg").Value, 0)
dteAct = NZ(rs.Fields("EffAct").Value, 0)
If dteAct > dteGRRCH Then
dteGRRCH = dteAct
End If
If dteTarg > dteGRRCH Then
dteGRRCH = dteTarg
End If
rs1.MoveNext
Wend
rs1.Close