I use the following hard coded database clearing routine in DAQ equipment that will collect data for a given test time & then it is no longer needed.
Private Sub pwdClearDatabase_Click()
Dim strConnectionString As String
Dim strFileSpec As String
Dim strDataSource As String
Dim rstMain As ADODB.Recordset
Dim intResp As Integer
' Confirm data deletion.
intResp = MsgBox("Clear Current DataBase Records?", vbYesNo + vbCritical, "Clear Database"
If (intResp = vbYes) Then
strFileSpec = App.Path & "\DbName.mdb"
strConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strFileSpec & _
";Persist Security Info=False"
Set rstMain = New ADODB.Recordset
rstMain.Open "DELETE * FROM MainDataTable", strConnectionString, adOpenKeyset, _
adLockOptimistic, adCmdText
Set rstMain = Nothing ' Close record set.
Call CompactDatabase ' DB compact & repair sub
MsgBox "DataBase Cleared"
End If
End Sub