Aug 8, 2002 #1 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
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
Aug 8, 2002 #2 DougP MIS Dec 13, 1999 5,985 US 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 = "Delete * From yourTablename" Rs1.Open SQLCode, Conn2, adOpenStatic, adLockOptimistic ' close it this way Set rs1 = nothing Set Conn2 = nothing DougP, MCP Upvote 0 Downvote
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 = "Delete * From yourTablename" Rs1.Open SQLCode, Conn2, adOpenStatic, adLockOptimistic ' close it this way Set rs1 = nothing Set Conn2 = nothing DougP, MCP
Aug 8, 2002 Thread starter #3 DavidRock Programmer Jul 24, 2002 61 US Thank you - exactly what I needed. Upvote 0 Downvote