Posted By

gtree on 01/23/14


Tagged


Versions (?)

Delete records from table based on a query


 / Published in: Visual Basic
 

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

  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  

You need to login to post a comment.