How to delete data from a table in VBA Access

2

I need a command in to delete the records from my table REPETIRTEL the moment I close my form. This form does not have this table as the data source, so I need the command to call this table and then disable the delete commit message.

    
asked by anonymous 13.03.2014 / 20:35

2 answers

2

First I created a delete query from the REPETIRTEL table with the Delete Query, then I called this query and that's it, it looks like this:

 Private Sub Form_Close()
  Application.DoCmd.SetWarnings False
  DoCmd.OpenQuery "deleteREPETIRTEL", acViewNormal
  Application.DoCmd.SetWarnings True
 End Sub

First I disabled access messages I called Query Re-enabled the messages.

    
14.03.2014 / 19:48
0

Another alternative:

Private Sub Form_Close()
  Application.DoCmd.SetWarnings False
  Application.DoCmd.RunSQL "DELETE * FROM REPETIRTEL"
  Application.DoCmd.SetWarnings True
End Sub
    
14.03.2017 / 12:53