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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete all records

Status
Not open for further replies.

DavidRock

Programmer
Jul 24, 2002
61
US
Can someone give me an example piece of VBA code that will simply delete all of the records in an Access table (empty it)?

Thanks,
David
 
Dim Conn2 As ADODB.Connection
Dim Rs1 As ADODB.Recordset

Dim SQLCode As String

Set Conn2 = CurrentProject.Connection ' <<<<Note same as CurrentDb

Set Rs1 = New ADODB.Recordset

SQLCode = &quot;Delete * From yourTablename&quot;
Rs1.Open SQLCode, Conn2, adOpenStatic, adLockOptimistic

' close it this way
Set rs1 = nothing
Set Conn2 = nothing
DougP, MCP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top