Hi all,
I have about 10 tables interlinked. Their name start by "tblActivity_..." and a common field is the "activityID".
I am trying to create a code to delete a specific activityID from all the tables.
I am using the following code where "rsActivity.Fields("activityID")" is the activityID I want to delete:
The first table it works OK but then, on the secod table, it returns the error 3167 Record is Deleted when running the strDelete="DELETE FROM...." line . Any ideas why?
Many thanks
Emanuel
I have about 10 tables interlinked. Their name start by "tblActivity_..." and a common field is the "activityID".
I am trying to create a code to delete a specific activityID from all the tables.
I am using the following code where "rsActivity.Fields("activityID")" is the activityID I want to delete:
Code:
For Each tdf In db.TableDefs
' If Connect property is non-empty, table will be checked.
If Len(tdf.Connect) > 0 Then
'Will check if tbl is an Activity table
If Left$(tdf.name, 11) = "tblActivity" Then
' Set Delete command
strDelete = "DELETE FROM " & tdf.name & " WHERE [activityID] = " & rsActivity.Fields("activityID")
'Change the setting to False so don't ask to confirm deleting line
DoCmd.SetWarnings False
'execute delete command
DoCmd.RunSQL strDelete
'back to normal
DoCmd.SetWarnings True
End If
End If
Next tdf
The first table it works OK but then, on the secod table, it returns the error 3167 Record is Deleted when running the strDelete="DELETE FROM...." line . Any ideas why?
Many thanks
Emanuel