Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Clear all records from a table automatically

Status
Not open for further replies.

Roosters

Technical User
May 14, 2000
61
AU
Thank you MichaelRed for solving my last problem of automating the import of data from Excel. It works fine but now I have the problem that the previous data is retained - I need to delete all records from my table via code before impoting the new data.
 
try

docmd.runSQL "Delete * from [mytable]"

or

create a stored delete query and call it like so

sub cleartable()
dim qdf as querydef
set qdf=currentdb().querydefs("MyDelete")
qdf.execute
set qdf = nothing
end sub
 
Here's one approach of many

Dim rsAnyName as Recordset
Set rsAnyName.OpenRecordset("DELETE * From [TableName]")
rsAnyName.Close

HTH,
JC
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top