如何编程删除access表中所有数据

来源:百度知道 编辑:UC知道 时间:2024/05/25 11:45:32
用access做了一个文件名为"基表1"的数据库表,想在窗体中做一个"数据初始化"的按纽删除表中已记录的数据,不知如何对按纽编写代码,谢谢!

Private Sub 数据初始化_Click()
Dim stemp As Integer
Dim stemp1, stemp2 As String
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
stemp2 = "select * from 基表1"
rs.Open stemp2, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
If rs.RecordCount > 0 Then
stemp = MsgBox("really to remove them?", 257, "warning")
If stemp = 1 Then
stemp1 = "delete * from 基表1"
DoCmd.RunSQL stemp1
Else
Exit Sub
End If
MsgBox "The records have delete already!", vbExclamation, "information"
Else
MsgBox "Nothing to Remove", vbExclamation, "confirm"
End If
End Sub