clearing databases on entry

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I was wondering if it was possible to clear all database entries each time the database was entered, ie so you start with an empty table every time you open it?
 
Be careful with this - it will delete all records from the specified table,
and there's no way to get them back short of reverting to a backup copy.

Private Sub Form_Open(Cancel As Integer)

CurrentProject.Connection.Execute "DELETE * FROM YourTableName"
Me.Requery

End Sub

--
Brendan Reynolds (MVP)
(e-mail address removed)

bug289 said:
I was wondering if it was possible to clear all database entries each time
the database was entered, ie so you start with an empty table every time you
open it?
 
I have to wonder whether the usage of an Access database is correct in this
case: A database is used to store data (in Tables) for later use and in
your case, you want to start with empty Tables, i.e. no stored data when the
database is re-opened.

It sounds very much like a company I know that uses over 200 hundred Access
databases. All databases have the same structure and each database stores
minimal amount of data for ONE of the company's customers!

--
HTH
Van T. Dinh
MVP (Access)



bug289 said:
I was wondering if it was possible to clear all database entries each time
the database was entered, ie so you start with an empty table every time you
open it?
 
I agree it would be an unusual requirement. Off-hand, the only situation I
can think of where I might want to use it would be where I was temporarily
importing data from another data store for local analysis and reporting.
 
You can set up a delete query for each table that you want
to remove all rows from, and then, when opening the
database you can execute the query(ies) either through a
macro or (preferred method) using a module.

DoCmd.OpenQuery "name of delete query"

The above command (in Access 2000) in a module will delete
all rows from the table set up on the query while leaving
the table definition (keys, etc.) intact.

Hope this helps!
-----Original Message-----
I was wondering if it was possible to clear all database
entries each time the database was entered, ie so you
start with an empty table every time you open it?
 
I used to work for a UK financial services company which used this
kind of arrangement. Apparently, legislation required that each
client's data was held in separate databases. Makes it easier to
audit, perhaps.
 
Ah well, when legislation is involved, common sense frequently goes out of
the window! :-(
 
Perhaps, the legislation should be applicable to the government as well and
the government will have a database for each tax-payer, each registered
company, each association ... I sounds bloody bureaucratic to the extreme.

Has anyone taking the government to court for breaking the law yet?
 
Back
Top