VBA访问:如何将可更新记录集链接到可更新FORM并将更改保存在SQL Server中 [英] VBA Access: How to link an updatable recordset to an updatable FORM and save the changes in SQL Server

查看:182
本文介绍了VBA访问:如何将可更新记录集链接到可更新FORM并将更改保存在SQL Server中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过ADO从SQL Server检索数据并将其存储在ADODB Recordset中。然后,我将表格链接到该记录集。然后,我使用一些控件(标签,文本框,数据字段)以自动方式显示记录集中的信息(控件数据源设置为FORM / Recordset表名)。并正确显示了信息。

I retrieve data from a SQL Server through ADO and store it in a ADODB Recordset. Then, I link a FORM to this recordset. And then I use some controls (labels, textboxes, Data field) to show the information from the recordset, in an automatic way (control data source is set to the FORM/Recordset table name). And it shows the info correctly.

出现问题是因为它不会将更改(例如,在DATA控件中)更新到记录集和/或SQL Server中。 。记录集具有一个带有大量联接的SELECT,并且当我通过ODBC链接表时,控件将信息完美地更新到SQL Server中。但是我无法通过记录集获得相同的结果。我究竟做错了什么?是否有必要创建一个事件(afterupdate或onclick等)并进行单独的查询以将更改更新到SQL Server中?

The problem comes because it DOES NOT update the changes (for example in the DATA control) into the recordset and/or in the SQL Server. The recordset has a SELECT with a lot of joins, and when I link the tables through ODBC the controls update the info into the SQL Server perfectly. But I CAN'T achieve the same result with recordsets. What am I doing wrong? Is it necessary to create an event (afterupdate or onclick etc) and make a separate query to update the changes into the SQL Server?

当前它表示已读取表单仅因为未建立唯一表属性。

Currently it says that the form is read only because the "Unique table" property is not established.

谢谢

推荐答案

简单而原生的方法是链接通过ODBC,然后使用链接表和查询具有绑定表。

The easy and native method is to link the tables via ODBC, and then have a bound form using the linked tables and your query.

当然,如果您希望能够更改和修改查询,则查询必须是可更新的保存表单中的数据。

Of course, the query must be updateable if you wish to be able to alter and save data from the form.

这篇关于VBA访问:如何将可更新记录集链接到可更新FORM并将更改保存在SQL Server中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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