Try this code
' run a delete query to delete the related records from the subform
DoCmd.RunSQL "DELETE TableName.* FROM TableName Where
TableName.FieldName =" & Me.[KeyFieldThatJoinBothTables]
' Delete current record on main form
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
=============================================
If the key field is text field then change the delete sql to
DoCmd.RunSQL "DELETE TableName.* FROM TableName Where
TableName.FieldName ='" & Me.[KeyFieldThatJoinBothTables] & "'"
--
I hope that helped
Good luck
rico said:
I am trying to create a button on a form which deletes the current record but
ALSO the records linked to it the froms subform. If some one could suggest
some code to do this that would be great.
TIA
Rico