P
Penny
A2002, Single User, Windows XP Pro(SP2)
Hi All, I show here code that opens a recordset on a joined table query. The
DAO recordset throws an error at the 'rsRemoveDups.Delete' line. The error
message is '3218 : Could not update; currently locked'. I've hard coded the
SQL just to illustrate the point but it errors the same as when the SQL is
created dynamically from controls.
Why wont it let me delete the current record in the recordset?
----------------------
strRecordSource = "SELECT * FROM (tblCandidates LEFT JOIN
tblCandidatePositionTypesSought ON tblCandidates.CandidateKeyNum =
tblCandidatePositionTypesSought.CandidateKeyNum) LEFT JOIN
tblCandidateIndustryExperience ON tblCandidates.CandidateKeyNum =
tblCandidateIndustryExperience.CandidateKeyNum WHERE
[CandidatePositionTypeSought] Like 'Secretary*' and [Activated] = True ORDER
BY tblCandidates.CandidateKeyNum"
Dim db As DAO.Database
Dim rsRemoveDups As DAO.Recordset
Dim strLastCandidateID As String
Dim intCount As Integer
intCount = 0
Set db = CurrentDb()
Set rsRemoveDups = db.OpenRecordset(strRecordSource, dbOpenDynaset,
dbInconsistent, dbOptimistic)
rsRemoveDups.MoveFirst
If Not rsRemoveDups.BOF Or rsRemoveDups.EOF Then
Do Until rsRemoveDups.EOF = True
strLastCandidateID =
rsRemoveDups.Fields("tblCandidates.CandidateKeyNum").Value
Else
If
rsRemoveDups.Fields("tblCandidates.CandidateKeyNum").Value =
strLastCandidateID Then
strLastCandidateID =
rsRemoveDups.Fields("tblCandidates.CandidateKeyNum").Value
rsRemoveDups.Delete
Else
strLastCandidateID =
rsRemoveDups.Fields("tblCandidates.CandidateKeyNum").Value
End If
End If
intCount = intCount + 1
rsRemoveDups.MoveNext
Loop
End If
Hi All, I show here code that opens a recordset on a joined table query. The
DAO recordset throws an error at the 'rsRemoveDups.Delete' line. The error
message is '3218 : Could not update; currently locked'. I've hard coded the
SQL just to illustrate the point but it errors the same as when the SQL is
created dynamically from controls.
Why wont it let me delete the current record in the recordset?
----------------------
strRecordSource = "SELECT * FROM (tblCandidates LEFT JOIN
tblCandidatePositionTypesSought ON tblCandidates.CandidateKeyNum =
tblCandidatePositionTypesSought.CandidateKeyNum) LEFT JOIN
tblCandidateIndustryExperience ON tblCandidates.CandidateKeyNum =
tblCandidateIndustryExperience.CandidateKeyNum WHERE
[CandidatePositionTypeSought] Like 'Secretary*' and [Activated] = True ORDER
BY tblCandidates.CandidateKeyNum"
Dim db As DAO.Database
Dim rsRemoveDups As DAO.Recordset
Dim strLastCandidateID As String
Dim intCount As Integer
intCount = 0
Set db = CurrentDb()
Set rsRemoveDups = db.OpenRecordset(strRecordSource, dbOpenDynaset,
dbInconsistent, dbOptimistic)
rsRemoveDups.MoveFirst
If Not rsRemoveDups.BOF Or rsRemoveDups.EOF Then
Do Until rsRemoveDups.EOF = True
strLastCandidateID =
rsRemoveDups.Fields("tblCandidates.CandidateKeyNum").Value
Else
If
rsRemoveDups.Fields("tblCandidates.CandidateKeyNum").Value =
strLastCandidateID Then
strLastCandidateID =
rsRemoveDups.Fields("tblCandidates.CandidateKeyNum").Value
rsRemoveDups.Delete
Else
strLastCandidateID =
rsRemoveDups.Fields("tblCandidates.CandidateKeyNum").Value
End If
End If
intCount = intCount + 1
rsRemoveDups.MoveNext
Loop
End If