中国教程网论坛's Archiver

lpwr555 发表于 2008-1-7 18:37

access 删除 提示没有要删除的书籍

Private Sub 删除_Click()


On Error GoTo Exit_cmdAdd_Click

Dim rs As New ADODB.Recordset
Dim str As String
Dim cunzai As Boolean

    If IsNull(Me.书籍编号) Then
        MsgBox ("请输入书籍编号!")
        Else
    str = "select * from 书籍"
    Set rs = GetRS(str)
   
     End If
     
     
     '检查编号是否存在
     Do While Not (rs.EOF)
     
     If Me.书籍编号 = rs!书籍编号 Then
     cunzai = True
     End If
     rs.MoveNext
     Loop
     rs.Close
     
    '判断存在变量是否为真,并删除
   If cunzai = True Then
   '执行删除代码
   str = "delete * from 书籍 WHERE 书籍编号=""" & Me.书籍编号 & """"
   ExecuteSQL (str)
    MsgBox ("成功删除书籍!")
   Else
    MsgBox ("不存在要删除的书籍!")
   GoTo Exit_cmdAdd_Click
End If
Exit_cmdAdd_Click:
    Exit Sub

[[i] 本帖最后由 lpwr555 于 2008-1-7 18:40 编辑 [/i]]

页: [1]

Powered by Discuz! Archiver 6.1.0  © 2001-2007 Comsenz Inc.