Delete Table Data on Exit

qdata

New member
Local time
Today, 21:33
Joined
Mar 18, 2012
Messages
8
Hi all, This might be a silly question but is there anotherway to delete the data in a table after I exit a form. I have already tried to run this code (Docmd.DeleteObject acTable, "My Table Name") in the close event. Unfortunately it comes up with runtime error 3211 (the database engine could not lock table because it is already in use by another progress or person). My Database has only one form and on table.
Your help would be much appreciated. Thank you
 
There is a difference between deleting a Table and deleting the Records on that table.

If you want to delete the records only, add a Delete Query to your exit procedure.

You can do this in vba or macro.

Create a select query
Select * from...

Verify all records are returned. Change it to a Delete Query and add it to the vba code.
 
Thank you PNGBill. For your help. I have found another way on a diffrent forum which has worked for me.

Create a form that opens as hidden when your database is opened
Then in that form's UNLOAD event use

Code:
Dim strSQL As String
strSQL = "Delete * From YourTableNameHere"
CurrentDB.Execute strsSQL, dbFailonError
 
Creating a hidden form that is always open can be handy for other uses over time.:)
 

Users who are viewing this thread

Back
Top Bottom