Clear contents of a table on exit (1 Viewer)

andy_25

Registered User.
Local time
Today, 12:47
Joined
Jan 27, 2009
Messages
86
Hi,

I have a database and due to data protection reasons I need to clear the contents of a table when the database is closed down, is there a way of doing this?

I have tried using me.undo in the form events etc to stop the data actually writting to the table however this causes problems so I would just like to clear on exit (of the database or the form in question).

Any ideas?
 

PNGBill

Win10 Office Pro 2016
Local time
Today, 23:47
Joined
Jul 15, 2008
Messages
2,271
A form should clear when closed and a table can be cleared by a delete query deleting * in all fields.

Can you build into the Exit / Quit on your Menu to run the query and then quit.
 

boblarson

Smeghead
Local time
Today, 04:47
Joined
Jan 12, 2001
Messages
32,059
create a form that opens as hidden when your database is opened (you can do that using an autoexec macro).

Then in that form's UNLOAD event use

Code:
Dim strSQL As String

strSQL = "Delete * From YourTableNameHere"

CurrentDb.Execute strSQL, dbFailOnError
 

andy_25

Registered User.
Local time
Today, 12:47
Joined
Jan 27, 2009
Messages
86
create a form that opens as hidden when your database is opened (you can do that using an autoexec macro).

Then in that form's UNLOAD event use

Code:
Dim strSQL As String

strSQL = "Delete * From YourTableNameHere"

CurrentDb.Execute strSQL, dbFailOnError

Fantastic Bob, thanks a lot, I would have never been able to figure that out :)
 

Users who are viewing this thread

Top Bottom