设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

返回列表 发新帖
查看: 2396|回复: 2
打印 上一主题 下一主题

[其它] [求助]DeleteRecord"命令不可用

[复制链接]
跳转到指定楼层
1#
发表于 2007-3-29 08:39:00 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
我在一个窗体中加一个删除记录的按钮.....在删除记录的同时也删除相关编号的其它表

但不知为什么删除的时候出现 当前"DeleteRecord"命令不可用 的字句...删除不了...

Private Sub Command32_Click()
    On Error GoTo Err_Command32_Click

    If MsgBox("真的要删除该用户一切资料吗?", vbQuestion + vbYesNo + vbDefaultButton2, "删除确定") = vbYes Then

        Dim str2, str3, str4, str5 As String
        Dim str1 As Long
        str1 = Forms!用户修改!用户编号
        DoCmd.RunCommand acCmdSelectRecord
        DoCmd.RunCommand acCmdDeleteRecord
        str2 = "delete from 缴费情况 where 用户编号=" & str1
        CurrentDb.Execute str2
        str3 = "delete from 报停表 where 用户编号=" & str1
        CurrentDb.Execute str3
        str4 = "delete from 搬迁表 where 用户编号=" & str1
        CurrentDb.Execute str4
        str5 = "delete from 改名表 where 用户编号=" & str1
        CurrentDb.Execute str5

Exit_Command32_Click:
        Exit Sub

Err_Command32_Click:
        MsgBox Err.Description
        Resume Exit_Command32_Click

    End If
End Sub
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖 订阅订阅
2#
 楼主| 发表于 2007-3-29 08:40:00 | 只看该作者
        str1 = Forms!用户修改!用户编号
        DoCmd.RunCommand acCmdSelectRecord
        DoCmd.RunCommand acCmdDeleteRecord
        str2 = "delete from 缴费情况 where 用户编号=" & str1
        CurrentDb.Execute str2
        str3 = "delete from 报停表 where 用户编号=" & str1
        CurrentDb.Execute str3
        str4 = "delete from 搬迁表 where 用户编号=" & str1
        CurrentDb.Execute str4
        str5 = "delete from 改名表 where 用户编号=" & str1
        CurrentDb.Execute str5

Exit_Command32_Click:
        Exit Sub

Err_Command32_Click:
        MsgBox Err.Description
        Resume Exit_Command32_Click

    End If
End Sub



[此贴子已经被作者于2007-3-29 0:41:20编辑过]

3#
发表于 2007-3-29 16:55:00 | 只看该作者
将各表的关系设立好,只删除主表的记录就行了,其它的附表会自动删除的,这样就不用每个表都作删除处理
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-5-17 07:04 , Processed in 0.102047 second(s), 26 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表