删除表单视图中的记录:保留在删除之前选择的记录 [英] Deleting Records in Form View: stay on record selected prior to deletion

查看:246
本文介绍了删除表单视图中的记录:保留在删除之前选择的记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于我使用的所有Access数据库,当我选择在窗体视图中删除记录时,下一条记录将成为询问我是否确实要删除记录的消息的背景。这使我很难确认我确实选择了我想要摆脱的记录。我可以在删除之前保留所选的记录吗?

With all Access databases I have used, when I select to delete a record in Form view, the next record becomes the background for the message asking if I really want to delete a record. That makes it difficult to confirm that I really did select the record I wanted to get rid of. Can I make it stay on the record selected, prior to deletion?

推荐答案

根据表格的不同,有几种方法可以做到这一点。

我使用的是删除事件之前的表单,其中我使用一个消息框来显示有关所选记录的信息并要求确认。这适用于单个记录删除;但是,对于多个记录,还有一些其他的陷阱和确认方法。
A few ways to do this depending on the form.
What I use is the form''s before delete events, wherein I use a message-box that shows something about the selected record and asks for confirmation. This works well for single record deletions; however, for multiple records there are a few other ways to trap and confirm.


因为你没有提到你正在使用哪个版本的Access,所以当我查看时,我默认回到了v2003我的笔记。

你会发现以下内容对我有所帮助:
删除事件 - Access 2003 VBA语言参考
As you didn''t mention which version of Access you are using, I defaulted back to v2003 when looking at my notes.
You''ll find the following to be helpful I hope:
Delete Event - Access 2003 VBA Language Reference


我会做什么将创建一个删除记录的按钮。在按钮的On_Click事件中,它将首先显示一个消息框,询问您是否要使用VbYesNo按钮删除记录。如果是,则将警告设置为false,然后删除当前记录,然后将警告设置为true(这样您就不会意外地将警告关闭)。这样,在确认您确实要删除记录之前,表单不知道您正在删除记录。
What I would do would be to create a button that deletes the record. In the On_Click event of the button, it would first display a messagebox asking if you want to delete the record with VbYesNo buttons. If yes, then set the warnings to false and then delete the current record and then set the warnings back to true (so that you don''t accidentally leave it with the warnings off). This way, the form doesn''t know that you are deleting the record until after you have confirmed that you do want to delete the record.


这篇关于删除表单视图中的记录:保留在删除之前选择的记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆