如何编程删除access表中所有数据
用access做了一个文件名为"基表1"的数据库表,想在窗体中做一个"数据初始化"的按纽删除表中已记录的数据,不知如何对按纽编写代码,谢谢!...
用access做了一个文件名为"基表1"的数据库表,想在窗体中做一个"数据初始化"的按纽删除表中已记录的数据,不知如何对按纽编写代码,谢谢!
展开
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
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
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询