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 derfloh 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 from a work table in an Access Project

Status
Not open for further replies.

databaser

MIS
Feb 11, 2007
9
US
I need to truncate all records from a work table that reside in an Access Project database. This works but there has to be a faster way.

Strsql = "select * From DataWork"
tblVendorSalesRpt.Open Strsql, CurrentProject.Connection, adOpenDynamic, adLockOptimistic
If Not tblVendorSalesRpt.EOF Then
Do
tblVendorSalesRpt.Delete
tblVendorSalesRpt.MoveNext
Loop Until tblVendorSalesRpt.EOF
End If
Set tblVendorSalesRpt = Nothing
 
Code:
Dim cnnstr As String
Dim mycmd As ADODB.Command
Dim mycnn As ADODB.Connection
Set mycmd = New ADODB.Command
Set mycnn = New ADODB.Connection
mycnn.Open CurrentProject.Connection
mycmd.ActiveConnection = mycnn
mycmd.CommandType = adCmdText
mycmd.CommandText = "truncate table DataWork"
mycmd.Execute
 
And what about this ?
CurrentProject.Connection.Execute "DELETE FROM DataWork"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top