how do i auto delete tha data in the mdb file ?

i has 1 mdb file. name abc.mdb.

now i want to put a code in the command botton that can delete all
the data inside that file by presing just one botton.

how ?
JOHNHOAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

crazymanCommented:
You mean delete the whole file? if so use
kill("c:\abc.mdb").
0
JOHNHOAuthor Commented:
nope, it just delete all the data inside that file not delete the whole file.

lets say i has abc.mdb and inside it has 10 data, and now i want to delete that 10 data so that i can key in a new data inside that abc.mdb.

thanks
0
schworakCommented:
This will delete all records from all tables within any given MDB file...


Public Sub KillAllData(byval DataFile as String)
   dim DB as Database
   dim TD as Tabledef

   on error goto Oops
   set DB = OpenDatabase(DataFile,true,false) ' exclusive open

   for each TD in Database.Tabledefs
      if td.Attributes and dbSystemObject then
         ' System table, skip it
      else
         db.execute "Delete * from " & td.name
      end if
   next TD
Done:
   on error resume next
   db.close
   set db = nothing
   exit sub
Oops:
   msgbox err & ", " & err.description
   resume Done
end sub
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

lehketCommented:
If you are using the ADO object model for your data access, and you have a connection object (let's call it "connDB") instantiated,  then all you need to do is something like this:

Dim sSQL As String
ssQL = "Delete from MyTable1"
connDB.Execute sSQL
ssQL = "Delete from MyTable2"
connDB.Execute sSQL
[etc., for each table to be cleared]

Remember, you have to create the connection first by instantiating connDB and setting properties as required for your purposes.
0
BalsheCommented:
Dim Db As DataBase
Db.Execute " delete from Customers"
'----------------------------------
This Will Delete All Records Stored In Table Customers
You can repeat It for All Tables In A single Command Button

I Hope It Works With You
Good Luck
0
sonalchouhanCommented:
well use the select statement

dim db as database
dim rs as recordset


command_click
set db = opendatabase(mm.mdb)
set rs  = db.opendatabase("select * From mm.mdb")


db.execute = db.execute "Delete * from mm.mdb"


all tha best
sonal

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.