none
Delete records in a table if exist in another table RRS feed

  • Question

  • Good morning,

    I have a table named "ScanInventaireImporté" that has records especially a field named "SERRE" that has a barcode value.

    In another table named "tblInventaireDesSerres" that has records with a field also named "SERRE", I want to delete the records in this table if the field tblInventaireDesSerres.SERRE = ScanInventaireImporté.SERRE

    Here is more explanations:

    Thank you

    Claude from Quebec, Canada


    Claude Larocque

    Tuesday, April 11, 2017 5:08 AM

Answers

  • Execute the query

    DELETE SERRE FROM tblInventaireDesSerres WHERE SERRE In (SELECT SERRE FROM ScanInventaireImporté)

    You can save this as a delete query and execute it, or you can execute the SQL directly from VBA:

        Dim strSQL As String
        strSQL = "DELETE SERRE FROM tblInventaireDesSerres WHERE SERRE In " & _
            "(SELECT SERRE FROM ScanInventaireImporté)"
        CurrentDb.Execute strSQL, dbFailOnError


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    Tuesday, April 11, 2017 5:31 AM

All replies

  • Execute the query

    DELETE SERRE FROM tblInventaireDesSerres WHERE SERRE In (SELECT SERRE FROM ScanInventaireImporté)

    You can save this as a delete query and execute it, or you can execute the SQL directly from VBA:

        Dim strSQL As String
        strSQL = "DELETE SERRE FROM tblInventaireDesSerres WHERE SERRE In " & _
            "(SELECT SERRE FROM ScanInventaireImporté)"
        CurrentDb.Execute strSQL, dbFailOnError


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    Tuesday, April 11, 2017 5:31 AM
  • Thanks Hans,

    Works at first try... I knew it when I saw that was you... not the first time you help me, I appreciate...

    Claude


    Claude Larocque

    Tuesday, April 11, 2017 9:57 AM