Delete records from table based on a query

/ Published in: Visual Basic
Save to your folder(s)

Completed in Access where this example deletes whole record from tblAttachments based on the ID pulled from another query--Select statement in ( )-- that query pulls IDs which have a matching ID in both tblAttachments and tblEmails, and Date Completed in tblEmails is older than 6 months ago to date

Copy this code and paste it in your HTML
  1. DoCmd.RunSQL "DELETE * FROM tblAttachments WHERE tblAttachments.ID IN (SELECT tblAttachments.ID FROM tblAttachments INNER JOIN tblEmails ON tblAttachments.ID = tblEmails.ID WHERE (((tblEmails.[Date Completed])<DateAdd('m',-6,Date()))))"

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.