有没有一种方法来覆盖接入的自动记录更新与表单向导创建的2007表格? [英] Is there a way to override automatic record updating of Access 2007 forms created with Form Wizard?

查看:199
本文介绍了有没有一种方法来覆盖接入的自动记录更新与表单向导创建的2007表格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的访问VBA,并使用窗体向导,在表中显示的记录创建的窗体。这是一块蛋糕。

I'm new to Access VBA, and have created a form using the Form Wizard that displays records in a table. That's a piece of cake.

这是我与形式的行为,虽然是更新记录时,我走动的记录自动进行。

The behavior that I get with the form, though, is that updates to the records occur automatically when I move around records.

我想是有更新只发生时,如果单击更新按钮,我把形式。

What I'd like is to have the updates occur only when I click an "Update" button that I put in the form.

好像我可以构建从零开始的形式,更新所有的(无限)控制编程,然后更新以编程的控制记录,但是这似乎是太辛苦了。

It seems like I can construct the form from scratch, update all of the (unbounded) controls programmatically, and then update the record from the controls programmatically, but this seems like too much work.

有没有办法从内部获得关闭自动更新行为,或使用VBA code?

Is there a way to "turn off" the automatic updating behavior from within Access, or using VBA code?

谢谢!

推荐答案

正如罗伯特建议,您可以避免保存更改的记录被更新事件之前取消。在code会是这个样子:

As Robert suggested, you can avoid saving a changed record by canceling the before update event. The code would look something like this:

Private Sub Form_BeforeUpdate(Cancel As Integer)
    Me.Undo
    Cancel = True
End Sub

不过,这种方法需要你放弃你所做的记录的任何更改之前,您可以在动销。如果没有 Me.Undo ,你可以取消更新,但访问不会让你移动到其他记录。您必须保存或移动到另一个之前放弃更改当前记录。

However, that approach requires you discard any changes you've made to the record before you can move off it. Without Me.Undo, you can cancel the update, but Access won't allow you to move to a different record. You must either save or discard the changes to the current record before moving to another.

如果你想移动到其他记录,但不会放弃先改变,我认为你需要尝试断开连接的记录。这是你在​​内存中创建一个ADO记录集,而不是绑定到任何数据源。您可以添加一个命令按钮来保存你对命令的变化。如果这听起来是有用的,请参阅本文由丹尼Lesandrini在数据库日志:<一href="http://www.databasejournal.com/features/msaccess/article.php/3846361/Create-In-Memory-ADO-Recordsets.htm"相对=nofollow>创建内存ADO记录集

If you want to move to another record but not discard changes first, I think you need to try a disconnected recordset. It's an ADO recordset you create in memory, not bound to any data source. You can add a command button to save your changes on command. If it sounds useful, see this article by Danny Lesandrini at Database Journal: Create In-Memory ADO Recordsets

这篇关于有没有一种方法来覆盖接入的自动记录更新与表单向导创建的2007表格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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