Hi guys.
I need help in deleting a recordset. I have created a button to delete a record from a form, but the code behind it needs to delete all related records in other tables also, so it will run through several tables, select the relevant records in a recordset and delete them. THis is my code:
'DELETE FROM TBLINTEREST
strSQL = "SELECT TblInterestRelationship.* FROM TblInterestRelationship WHERE (((TblInterestRelationship.ContactID) = "
strSQL = strSQL & lngContactID
strSQL = strSQL & "));"
Set rsRecords = db.OpenRecordset(strSQL)
With rsRecords
If Not (.BOF And .EOF) Then
.Delete
End If
.Close
End With
strSQL = ""
Set rsRecords = Nothing
The thing is, it only appears to delete one of the records, not all of them. Can anyone help?
I need help in deleting a recordset. I have created a button to delete a record from a form, but the code behind it needs to delete all related records in other tables also, so it will run through several tables, select the relevant records in a recordset and delete them. THis is my code:
'DELETE FROM TBLINTEREST
strSQL = "SELECT TblInterestRelationship.* FROM TblInterestRelationship WHERE (((TblInterestRelationship.ContactID) = "
strSQL = strSQL & lngContactID
strSQL = strSQL & "));"
Set rsRecords = db.OpenRecordset(strSQL)
With rsRecords
If Not (.BOF And .EOF) Then
.Delete
End If
.Close
End With
strSQL = ""
Set rsRecords = Nothing
The thing is, it only appears to delete one of the records, not all of them. Can anyone help?