抑制Access VBA中的写冲突消息 [英] suppress write conflict message in Access VBA

查看:73
本文介绍了抑制Access VBA中的写冲突消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题.

我编写了一个存储过程,以计算通过Ms Access前端(至MSSQL2000 db)上的表单呈现的多个字段.

I have written a stored procedure to calculate a number of fields that are being presented through a form on an Ms Access front end (to a MSSQL2000 db).

我致电 Me.Form.Requery 以获取更改后的值.我可以引起我写冲突的刺激消息.

as soon as I call Me.Form.Requery to get the changed values. I can the irritating message that I have caused a write conflict.

自您开始编辑该记录以来,该记录已被其他用户更改.如果保存记录,则将覆盖其他用户所做的更改. 将更改的内容复制到剪贴板,您可以查看其他用户输入的值, 然后,如果您决定进行更改,则将其粘贴回.

This record has been changed by another user since you started editing it. If you save the record, you will overwrite the changes the other user made. Copying the changed to the clipboard will let you look at the values the other user entered, and then paste your changes back in if you decide to make changes.

我知道是我自己更改了数据,所以我想隐藏该消息或阻止该消息发生.

I know that its me that has changed the data so I want to suppress the message or prevent the message from occurring.

推荐答案

(我想我应该在评论中写评论,因为我实际上是在回答问题)

(I guess I should put my comments in a post, since I'm actually answering the question)

收到写冲突消息的原因是因为您通过通过表单和存储过程编辑记录而创建了写冲突.为避免错误,只需在执行存储过程之前将记录保存在表单中即可.从上面发布的代码段中,应该是:

The reason you're getting the write conflict message is because you've created a write conflict by editing the record via the form and via the stored procedure. To avoid the error, simply save the record in the form before executing the stored procedure. From your code snippet posted above, it should be:

Me.Dirty = False
cmd.Execute , , adCmdStoredProc

这是一个常见的Access错误,由尝试通过绑定形式和直接SQL更新来编辑数据引起.您需要先保存表单的编辑缓冲区,然后才能通过SQL更新同一条记录.

This is a common Access error, and it's caused by trying to edit the data through a bound form and through direct SQL updates. You need to save the edit buffer of the form before updating the same record via SQL.

换句话说,您应该感谢错误消息的发生,否则,您将丢失其中一项更改.

In other words, you should be grateful that the error message is happening, because otherwise, you'd lose one or the other of the changes.

不过,我质疑设计.如果您以绑定形式打开了记录,则对表单中加载的数据进行编辑,而不是运行SQL来更新它.我不确定为什么需要一个存储过程来更改已经以表格形式编辑过的记录-对我来说这听起来像是设计错误(即使解决方案非常简单).

I question the design, though. If you've got the record open in a bound form, then make the edits to the data loaded in the form, rather than running SQL to update it. I'm not sure why you need a stored procedure to make changes to a record you've already edited in a form -- it sounds like a design error to me (even if the solution is quite simple).

这篇关于抑制Access VBA中的写冲突消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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