How to delete data from a VBA Access table

Asked

Viewed 7,009 times

2

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

2 answers

2


First I created a query deleting the REPETIRTEL table with the Delete query, then I called this query and that’s it, it was 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 the Query I enabled the messages again.

0

Alternative:

Private Sub Form_Close()
  Application.DoCmd.SetWarnings False
  Application.DoCmd.RunSQL "DELETE * FROM REPETIRTEL"
  Application.DoCmd.SetWarnings True
End Sub

Browser other questions tagged

You are not signed in. Login or sign up in order to post.