[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

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

Posted on 1999-11-18
6
Medium Priority
?
301 Views
Last Modified: 2010-05-02
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 ?
0
Comment
Question by:JOHNHO
6 Comments
 
LVL 13

Expert Comment

by:crazyman
ID: 2216630
You mean delete the whole file? if so use
kill("c:\abc.mdb").
0
 

Author Comment

by:JOHNHO
ID: 2216706
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
 
LVL 3

Accepted Solution

by:
schworak earned 200 total points
ID: 2216973
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
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
LVL 1

Expert Comment

by:lehket
ID: 2216990
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
 
LVL 1

Expert Comment

by:Balshe
ID: 2217918
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
 

Expert Comment

by:sonalchouhan
ID: 2219545
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

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

640 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question